Message-Id: <199903310411.XAA09206@delorie.com> Comments: Authenticated sender is From: "George Foot" To: "Andrew Davidson" Date: Wed, 31 Mar 1999 05:09:17 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: How does DJGPP store its structs? CC: djgpp AT delorie DOT com X-mailer: Pegasus Mail for Win32 (v2.42a) Reply-To: djgpp AT delorie DOT com On 31 Mar 99 at 4:00, Andrew Davidson wrote: > I've tested the structs and all stuff done from within C code works fine. > Is this 12 byte thing the result of the way I'm trying to use the scratch > struct (from within another struct) or just a limitation of djgpp? I have a > feeling that djgpp might be trying to optimise the struct so is there any > way I can dissable this optimisation while keeping all the other forms of > optimisation available? gcc is padding the structs with dead space to align the fields for speed. To tell it not to do this, put `__attribute__ ((__packed__))' after the struct definition, or if the code is C++, put it after every field in the struct. In both cases, it goes before the semicolon. C example: struct foo { char a; int b; } __attribute__ ((__packed__)); C++ example: struct bar { char a __attribute__ ((__packed__)); int b __attribute__ ((__packed__)); }; The C++ way works in C too, but it's more hassle. -- George