Message-ID: <3702984D.34D44A88@scordon.com.br> Date: Wed, 31 Mar 1999 18:49:02 -0300 From: producao <producao AT scordon DOT com DOT br> X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: How does DJGPP store its structs? References: <199903310411 DOT XAA09206 AT delorie DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com George Foot wrote: > 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__)); > }; > Or use -fpack-struct. > The C++ way works in C too, but it's more hassle. > > -- > George