On Saturday 06 May 2006 06:18, Lan Qing wrote:
> the struct in_addr have only one variable in it, is there any necessary to
> define a struct like that?
> why not use "typedef in_addr_t in_addr;" directly?

POSIX (the standard for UNIX software) states that: "The <netinet/in.h> header 
shall define the in_addr structure that includes at least the following 
member: in_addr_t  s_addr", as you can see for youself at:
http://www.opengroup.org/onlinepubs/009695399/basedefs/netinet/in.h.html

So it's a structure because it has to contain AT LEAST that one member :-)

But as Hannes Gredler pointed out, the result will be exactly the same wether 
it's a typedef or a structure: the former will be transformed by the compiler 
into a reference to some memory address containing 4 bytes, and the latter 
into a reference to some memory address containing a structure with an offset 
of 0 to access its first 4 bytes...

-- 
Sébastien Raveau
computer and network security student
head of the hawKeye network monitor project
http://hawkeye.sourceforge.net/

Attachment: pgpts76JtXpsf.pgp
Description: PGP signature

Reply via email to