On Thu, May 25, 2006 at 11:20:06PM +0200, Michael Kerrisk wrote: > Justin, > > > On Tue, May 23, 2006 at 10:07:57PM +0200, Michael Kerrisk wrote: > > > > \fBoffsetof\fP() is a macro provided to compute the offset of a given > > > > element within a structure. The ordering within memory of a C > > > > structure is undefined, as is its size; compilers are allowed to > > > > reorder and pad structures. > > > ^^^^^^^ > > > Is that really true? I can't recall a case where I have ever seen > > > that, nor do I recall some such statement in the standards. > > > Please tell me more. > > > I couldn't find anything to back this up, so you might be right.. > > Umm -- where did the words come from then? I wrote them because I thought it was true in the most general case; I haven't been able to verify it, and actually the glibc-doc example you mention for readdir_r suggests otherwise.
> > One reason such things aren't as noticable is because most network > > protocols put the members in decreasing order of size, in an attempt > > to satisty the requirements for alignment and such, and inhibit any > > such compiler-specific :) things. > > ? Low level network protocols have no idea about the semantics of > bytes from higher layers. They won't do any reordering. The structure members of eg. a TCP packet are laid out such that compilers won't need to do any padding; /usr/include/netinet/tcp.h. Justin -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]