This is the mail archive of the gcc@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: [RFC] Removing -fpack-struct in C++ for 4.0


Dave Korn wrote:

>   Yeh, it's used in embedded code, and it's handy for accessing data
> structs that may be sent at arbitrary alignment in a stream of
> network or file data.

The same can be done with either pragma pack or attribute((packed)). But this
way you can mark which structures you want to be laid out like that, and
structures used in system and external headers are not affected. -fpack-struct
does not provide any additional semantic to GCC that cannot be obtained
otherwise. It is just the wrong approach because it basically forces an ABI
change.

By putting pragma pack at the top of each file (or of a main global header) you
obtain the very same effect of -fpack-struct. And then, you can put it just a
few lines below the standard headers, and have only your structures packed.

>   People are still currently using as well, e.g.
>
> http://groups.google.com/groups?hl=en&lr=&scoring=d&q=fpack-struct

It's funny that the first link there (in French) is someone which asks
explanation about -fpack-struct: he doesn't understand how an user can mixmatch
code compiled with -fpack-struct with code compiled without it. So, I would
even argue that this option is caused confusion to our users. Later, another
link is to a message saying that it's better to avoid -fpack-struct and use
attribute((packed)) instead.

Giovanni Bajo



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