* C language(asm construct)
@ 2004-10-06 10:44 Ankit Jain
2004-10-06 21:47 ` passing host name from a structure Edward Parrilla
2004-10-08 15:02 ` C language(asm construct) Suciu Flavius
0 siblings, 2 replies; 8+ messages in thread
From: Ankit Jain @ 2004-10-06 10:44 UTC (permalink / raw)
To: linux prg
hi
i want to know if this is correct? i am a bit confused
about linker...i am talking this topic when we have a
asm construct in our code.
The compiler basically reads the .c program and
converts it into assembly code.Now during this it
neglects this assembler construct and leaves it for
assembler.Assembler is the person which basically
looks for this part of the code and changes it into
machine code.
thanks
ankit
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* passing host name from a structure.
2004-10-06 10:44 C language(asm construct) Ankit Jain
@ 2004-10-06 21:47 ` Edward Parrilla
2004-10-06 22:44 ` Alphex Kaanoken
2004-10-07 5:03 ` Jeff Woods
2004-10-08 15:02 ` C language(asm construct) Suciu Flavius
1 sibling, 2 replies; 8+ messages in thread
From: Edward Parrilla @ 2004-10-06 21:47 UTC (permalink / raw)
To: linux prg
Hi Experts,
here a question for you, I have defined the following
#define bcopy(a,b,c) strncpy(b,a,c)
struct sockaddr_in sa; /* socket addr. structure */
struct hostent * hp; /* host entry */
char *hostname;
hostname=argv[3];
hp=gethostbyname(hostname); <-- get this error " warning: assignment
makes pointer from integer without a cast
"
bcopy((char *)hp->h_addr, (char *)&sa.sin_addr, hp->h_length); <--
getting dereferencing pointer to incomplete type
Any idea?
thanks in advance
Edward
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: passing host name from a structure.
2004-10-06 21:47 ` passing host name from a structure Edward Parrilla
@ 2004-10-06 22:44 ` Alphex Kaanoken
2004-10-07 2:02 ` Edward Parrilla
2004-10-07 5:03 ` Jeff Woods
1 sibling, 1 reply; 8+ messages in thread
From: Alphex Kaanoken @ 2004-10-06 22:44 UTC (permalink / raw)
To: Edward Parrilla; +Cc: linux-c-programming
On 06 Oct 2004 16:47:27 -0500
Edward Parrilla <eparrilla@comcast.net> wrote:
> Hi Experts,
> here a question for you, I have defined the following
>
>
> #define bcopy(a,b,c) strncpy(b,a,c)
>
>
> struct sockaddr_in sa; /* socket addr. structure */
> struct hostent * hp; /* host entry */
> char *hostname;
>
> hostname=argv[3];
>
> hp=gethostbyname(hostname); <-- get this error " warning: assignment
> makes pointer from integer without a cast
> "
so, it's wrong write
hp=gethostbyname((const char*)hostname);/*but why you need pointer hostname? may be use argv[3] instead?*/
see `man gethostbyname' for details
>
>
> bcopy((char *)hp->h_addr, (char *)&sa.sin_addr, hp->h_length); <--
> getting dereferencing pointer to incomplete type
>
> Any idea?
> thanks in advance
> Edward
>
>
>
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Alphex Kaanoken,
Senior Developer of
Crew IT research labs.
Web: http://crew.org.ru
Mail: kaanoken at crew.org.ru
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: passing host name from a structure.
2004-10-06 22:44 ` Alphex Kaanoken
@ 2004-10-07 2:02 ` Edward Parrilla
0 siblings, 0 replies; 8+ messages in thread
From: Edward Parrilla @ 2004-10-07 2:02 UTC (permalink / raw)
To: kaanoken; +Cc: linux prg
I tried with that it didn't work. It works when I add the
#include <netdb.h>
however when I add that library, it doesn't allow the "fprintf" and
"strupr" to work, any ideas?
Got the following error
/tmp/ccD8SAtf.o(.text+0x37f): In function `main':
: undefined reference to `fprint'
appears as "fprint" even when I put "fprintf"
any ideas?
On Wed, 2004-10-06 at 17:44, Alphex Kaanoken wrote:
> On 06 Oct 2004 16:47:27 -0500
> Edward Parrilla <eparrilla@comcast.net> wrote:
>
> > Hi Experts,
> > here a question for you, I have defined the following
> >
> >
> > #define bcopy(a,b,c) strncpy(b,a,c)
> >
> >
> > struct sockaddr_in sa; /* socket addr. structure */
> > struct hostent * hp; /* host entry */
> > char *hostname;
> >
> > hostname=argv[3];
> >
> > hp=gethostbyname(hostname); <-- get this error " warning: assignment
> > makes pointer from integer without a cast
> > "
> so, it's wrong write
> hp=gethostbyname((const char*)hostname);/*but why you need pointer hostname? may be use argv[3] instead?*/
> see `man gethostbyname' for details
> >
> >
> > bcopy((char *)hp->h_addr, (char *)&sa.sin_addr, hp->h_length); <--
> > getting dereferencing pointer to incomplete type
> >
> > Any idea?
> > thanks in advance
> > Edward
> >
> >
> >
> >
> >
> >
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: passing host name from a structure.
2004-10-06 21:47 ` passing host name from a structure Edward Parrilla
2004-10-06 22:44 ` Alphex Kaanoken
@ 2004-10-07 5:03 ` Jeff Woods
2004-10-07 6:23 ` Edward Parrilla
2004-10-07 6:34 ` mapping client to port Edward Parrilla
1 sibling, 2 replies; 8+ messages in thread
From: Jeff Woods @ 2004-10-07 5:03 UTC (permalink / raw)
To: Edward Parrilla; +Cc: linux prg
At 10/6/2004 04:47 PM -0500, Edward Parrilla wrote:
>#define bcopy(a,b,c) strncpy(b,a,c)
>
> struct sockaddr_in sa; /* socket addr. structure */
> struct hostent * hp; /* host entry */
> char *hostname;
>
>hostname=argv[3];
>
>hp=gethostbyname(hostname); <-- get this error " warning: assignment
>makes pointer from integer without a cast"
This error looks really peculiar. IIUC, it's complaining that
gethostbyname() returns an int (or other ordinal value) which must be
converted to a pointer for assignment to "hp". However, on my system "man
gethostbyname" says "struct hostent *gethostbyname(const char *name);"
which says it should be returning a pointer (even one of the same type as
you declared "hp"). Have you declared a prototype for gethostbyname()? If
not, then the compiler assumes the function returns an int. The same man
page indicates you should include this line in your source: "#include
<netdb.h>". Just to be sure, check "man gethostbyname" on your system and
see what include files it recommends and what type gethostbyname()
returns. If you've confirmed that's not the problem, then you might dig
into the include file(s), find the prototype being used for gethostbyname()
and see that it's correct; but that's very unlikely to be the
problem. (Someone else would have seen it a long time ago.)
>bcopy((char *)hp->h_addr, (char *)&sa.sin_addr, hp->h_length); <--
>getting dereferencing pointer to incomplete type
The problem is the precedence of "(char *)hp->h_addr". The cast "()" and
indirection "->" operators have equal precedence level and so left-to-right
order determines precedence, which means you told the compile to access the
h_addr struct field of what you just told it is a char. I think you mean
"(char *)(hp->h_addr)". Note also that some groups of operators at the
same precedence level operate left to right [e.g., arithmetic: (a + b - c)]
and others operate right to left [e.g., assignments: (a *= b +=2)].
--
Jeff Woods <kazrak+kernel@cesmail.net>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: passing host name from a structure.
2004-10-07 5:03 ` Jeff Woods
@ 2004-10-07 6:23 ` Edward Parrilla
2004-10-07 6:34 ` mapping client to port Edward Parrilla
1 sibling, 0 replies; 8+ messages in thread
From: Edward Parrilla @ 2004-10-07 6:23 UTC (permalink / raw)
To: linux prg
Thanks,
you were right, it was my mistake I was putting "fprintff" instead of
"fprintf"
On Thu, 2004-10-07 at 00:03, Jeff Woods wrote:
> At 10/6/2004 04:47 PM -0500, Edward Parrilla wrote:
> >#define bcopy(a,b,c) strncpy(b,a,c)
> >
> > struct sockaddr_in sa; /* socket addr. structure */
> > struct hostent * hp; /* host entry */
> > char *hostname;
> >
> >hostname=argv[3];
> >
> >hp=gethostbyname(hostname); <-- get this error " warning: assignment
> >makes pointer from integer without a cast"
>
> This error looks really peculiar. IIUC, it's complaining that
> gethostbyname() returns an int (or other ordinal value) which must be
> converted to a pointer for assignment to "hp". However, on my system "man
> gethostbyname" says "struct hostent *gethostbyname(const char *name);"
> which says it should be returning a pointer (even one of the same type as
> you declared "hp"). Have you declared a prototype for gethostbyname()? If
> not, then the compiler assumes the function returns an int. The same man
> page indicates you should include this line in your source: "#include
> <netdb.h>". Just to be sure, check "man gethostbyname" on your system and
> see what include files it recommends and what type gethostbyname()
> returns. If you've confirmed that's not the problem, then you might dig
> into the include file(s), find the prototype being used for gethostbyname()
> and see that it's correct; but that's very unlikely to be the
> problem. (Someone else would have seen it a long time ago.)
>
> >bcopy((char *)hp->h_addr, (char *)&sa.sin_addr, hp->h_length); <--
> >getting dereferencing pointer to incomplete type
>
> The problem is the precedence of "(char *)hp->h_addr". The cast "()" and
> indirection "->" operators have equal precedence level and so left-to-right
> order determines precedence, which means you told the compile to access the
> h_addr struct field of what you just told it is a char. I think you mean
> "(char *)(hp->h_addr)". Note also that some groups of operators at the
> same precedence level operate left to right [e.g., arithmetic: (a + b - c)]
> and others operate right to left [e.g., assignments: (a *= b +=2)].
>
> --
> Jeff Woods <kazrak+kernel@cesmail.net>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* mapping client to port
2004-10-07 5:03 ` Jeff Woods
2004-10-07 6:23 ` Edward Parrilla
@ 2004-10-07 6:34 ` Edward Parrilla
1 sibling, 0 replies; 8+ messages in thread
From: Edward Parrilla @ 2004-10-07 6:34 UTC (permalink / raw)
To: linux prg
Hi all,
sorry again for bothering you:
I have the following entry to do:
myprog port1 port2 servname
that will be executed from the client's command line.
where
port1 is the client's port
port2 is the server's port
and servname is the server to which I want to connect.
In order to associate port2 with servername I have to create a
struct servent *serv;
struct socket_in *fin;
then associate it with
fin.sin_port -->getservbyname(port2)
the question is how do to associate the port1 to the local host?
is it valid if I do:
fin.in_port = htons(atoi(port1))
Thanks in advance for your help
Edward
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: C language(asm construct)
2004-10-06 10:44 C language(asm construct) Ankit Jain
2004-10-06 21:47 ` passing host name from a structure Edward Parrilla
@ 2004-10-08 15:02 ` Suciu Flavius
1 sibling, 0 replies; 8+ messages in thread
From: Suciu Flavius @ 2004-10-08 15:02 UTC (permalink / raw)
To: linux-c-programming
Hi,
Steps:
1) write hello_world.c
2) the preprocesor parse you hello_world.c file, process every #
starting commands (like #include #define #ifdef ...) and generate a
temporary file
3) the compiler start it's job reading the c file, parsing it, checking
it for errors, optimizing it and generating an assembler file
4) the assembler generate than the obj files
5) the linker solve the libraries, global variables referencing, etc and
generate the executable which of course, is in machine code and platform
dependent.
Retain that step 4 can be optional, the compiler can generate object
files without an assembler, it depending on the compilers ;)
So, to move your compiler on another platform, you need a new assembler
and linker, the compiler can be the same. Look for example at GNU
Compiler family ;)
For more info read
Aho, Sethi, Ullman - Compilers Principles, Techinques, And Tools
Ankit Jain wrote:
> hi
>
> i want to know if this is correct? i am a bit confused
> about linker...i am talking this topic when we have a
> asm construct in our code.
>
> The compiler basically reads the .c program and
> converts it into assembly code.Now during this it
> neglects this assembler construct and leaves it for
> assembler.Assembler is the person which basically
> looks for this part of the code and changes it into
> machine code.
>
> thanks
>
> ankit
>
> ________________________________________________________________________
> Yahoo! Messenger - Communicate instantly..."Ping"
> your friends today! Download Messenger Now
> http://uk.messenger.yahoo.com/download/index.html
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-10-08 15:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-06 10:44 C language(asm construct) Ankit Jain
2004-10-06 21:47 ` passing host name from a structure Edward Parrilla
2004-10-06 22:44 ` Alphex Kaanoken
2004-10-07 2:02 ` Edward Parrilla
2004-10-07 5:03 ` Jeff Woods
2004-10-07 6:23 ` Edward Parrilla
2004-10-07 6:34 ` mapping client to port Edward Parrilla
2004-10-08 15:02 ` C language(asm construct) Suciu Flavius
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).