This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc and attribute __packed__
- From: Andrew Haley <aph at redhat dot com>
- To: Nicolas DICHTEL <nicolas dot dichtel at 6wind dot com>
- Cc: gcc at gnu dot org
- Date: Fri, 10 Feb 2006 16:38:58 +0000
- Subject: Re: gcc and attribute __packed__
- References: <43ECB7A4.1070205@6wind.com>
Nicolas DICHTEL writes:
> Hi all,
>
> here is the result on ARM of my little program:
>
> root@lanner128:/usr/admin# ./test2
> 4 5 6 8
> 2 3 4 6
>
>
> Is it normal to add an attribute __packed__ on each union{}
> contained in a structure, or is it a bug of my compiler ?
> On X86, this kind of structure has always the good size.
gcc doesn't pack structs by default, but adheres to the ABI of the
platform being targeted. If you ask for a union to be packed, you're
allowing gcc to do something different from the platform ABI.
gcc developers don't usually get to design the platform ABI. We
merely try to write a compiler that implements it correctly.
Andrew.