Mail Archives: djgpp/1999/04/01/17:18:10
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
- Raw text -