This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: packed structures


Frank Cornelis wrote:
When I mark a structure with __attribute__((packed)) and that structure
has inner-structs, these inner-structs no longer are packed.

attribute packed only affects the type that it is applied to. It does not affect outer or inner types. As far as I know, it has always worked this way.


If we changed attribute packed to affect inner types, then we would be reducing the power of this feature, as then it would no longer be possible to unpacked structures inside packed structure. That is a reasonable thing that some users might want to do, so we should not exclude the possibility.

If you have a structure with inner types that you also want packed, then you must apply attribute packed to the inner types. An alternative would be to enable pragma pack across the structure, but you have to be careful to disable it after the structure, so it is usually less convenient.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]