This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: data alignment
- To: Silvio Bandeira <silvio at dei dot unicap dot br>
- Subject: Re: data alignment
- From: Michael Meissner <meissner at cygnus dot com>
- Date: Tue, 12 Sep 2000 20:52:21 -0400
- Cc: gcc <gcc at gcc dot gnu dot org>
- References: <39BEA0BB.8D2CC249@dei.unicap.br>
On Tue, Sep 12, 2000 at 05:31:39PM -0400, Silvio Bandeira wrote:
> Hi guys,
>
> Do you know how to control arrays and structures alignment using gcc
> ? I need them "packed".
> I've used "__attribute__ ((packed))" after defining a struct, but it
> decreases portability. Is there a more "clean" way to specify that for
> all data structures?
> I've also tried "#pragma pack(1)" but gcc says "ignoring pragma".
> Thanks in advance for any information.
There is no 'clean' method of doing this. In fact, many compilers offer no
means of overriding the default packing rules. Also note, that you can't even
be guaranteed that an unsigned char is 8 bits (though it will be true in many
machines, but not all, including some machines that GCC targets).
--
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: meissner@redhat.com phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org fax: +1 978-692-4482