This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Removing -fpack-struct in C++ for 4.0
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: "Dave Korn" <dk at artimi dot com>,"'Andrew Haley'" <aph at redhat dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Thu, 7 Oct 2004 15:06:12 +0200
- Subject: Re: [RFC] Removing -fpack-struct in C++ for 4.0
- References: <NUTMEGr4YFM8De4wk2U000002ee@NUTMEG.CAM.ARTIMI.COM>
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