Date: Sat, 28 Jan 1995 12:01:46 -0800 (PST) From: Gordon Hogenson To: Jason Hoffoss Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: Major bug On Fri, 27 Jan 1995, Jason Hoffoss wrote: > Then, I put in a debugging line like: > > printf("%d\n", sizeof(header)); > > Which gave me 24 for output. If you look carefully, however, you will see That's not a bug. Nothing in the C standard requires structs to be layed out in a particular way. Code that depends on the exact layout of a structure is inherently non-portable. GCC aligns elements of a struct as it sees fit, for efficiency. If you want a struct to be packed (i.e. no space in-between elements), you must use the __attribute__ ((packed)) notation on each element of the structure (see the info pages). That is a subtle gotcha, though...... I don't know if it's possible to get gcc to issue a warning in cases like this. Gordon.