This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: attribute ((packed)) on variables
- To: Christian Häggström <97nv46 at skola dot kiruna dot se>
- Subject: Re: attribute ((packed)) on variables
- From: Michael Meissner <meissner at cygnus dot com>
- Date: Wed, 12 Apr 2000 18:11:30 -0400
- Cc: gcc at gcc dot gnu dot org
- References: <s8f48c04.047@ymer>
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