tcpdump mailing list archives
Re: about struct in_addr
From: "Lan Qing" <efiish () gmail com>
Date: Mon, 8 May 2006 13:10:38 +0800
So,never mind it is a structure or a typedef,it point to the same memory address,to use a structure only for it's historical reason like Guy Harris said? On 5/7/06, Sebastien Raveau <sebastien.raveau () epita fr> wrote:
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/
- This is the tcpdump-workers list. Visit https://lists.sandelman.ca/ to unsubscribe.
Current thread:
- about struct in_addr Lan Qing (May 05)
- Re: about struct in_addr Hannes Gredler (May 06)
- Re: about struct in_addr Guy Harris (May 06)
- Re: about struct in_addr Sebastien Raveau (May 06)
- Re: about struct in_addr Lan Qing (May 08)