Re: Packing of structure fields and whole structs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> The Linux people have read this in the gcc docs:
>
>    Specifying this attribute [packed] for `struct' and `union' types is
> equivalent to specifying the `packed' attribute on each of the structure or
> union members.
>
> I think this is almost, but not quite, true - specifying the attribute
> on the struct itself also affects packing when the struct is used, not
> just the packing of the fields themselves.

No it doesn't. The normal rules apply.
The alignment of a structure is generally the maximum alignment of its 
members. In a packed structure all fields have byte alignment, therefore the 
structure as a whole also has byte alignment.

IMHO this is the only definition that makes sense.

Paul

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux