attribute ((packed)) on variables
Michael Meissner
meissner@cygnus.com
Wed Apr 12 15:11:00 GMT 2000
On Wed, Apr 12, 2000 at 02:45:03PM +0200, Christian Häggström wrote:
> neither of the following declarations changes the alignment; gcc forces a 32-byte align:
>
> char name[33] __attribute__((aligned(1)));
> char name[33] __attribute__((packed));
>
> My question is: Is there any way to (mis)align objects larger than 32 byte?
>
> I use gcc 2.95.2 on a pentium.
(you didn't mention the OS, which is crucial in this case, since each OS or
object file format could define the macro or not).
It depends on the target, and whether it defines MAX_OFILE_ALIGNMENT or not.
If it doesn't define it, then you are limited to the maximum alignment for
types (this is due to the specification of the original UNIX a.out object file
which did not have the ability to align sections). IIRC, elf systems (ie,
Linux) did not define MAX_OFILE_ALIGNMENT in 2.95, but do define it in the
current snapshot.
--
Michael Meissner, Cygnus Solutions, a Red Hat company.
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
More information about the Gcc
mailing list