This was discussed at length earlier in the linux-arm newsgroups.

Unfortunately, (IMHO) the linux-arm port of GCC aligns all structures
to a word boundary, even if it only contains bytes.  ARM is the only
port which does this and it does so for no real good architectural reason.
Probably this originated with some old ACORN boards which couldn't access
bytes because they didn't have lower address strobes.

Yes, it's valid for a C compiler to align structures however it sees fit,
however there's alot of software that assumes a C compiler won't align a
structure which contains only byte aligned fields.

You can use the __attribute__((packed)) option in GCC to work around
this problem on the ARM.  For example, the structure below could be written
as:

        struct foo{
                u8 buf[5];
                u8 frame[0];
        } __attribute__((packed));

On Fri, 15 Sep 2000 09:45:27 Xavier DEBREUIL wrote:
> Hello,
> 
> Consider the following structure :
> struct foo{
>   u8 buf[5];  
>   u8 frame[0];  
> } ;
> 
> sizeof( foo ) returns 8  when I use the arm-linux-gcc : why is this ? could
> someone explain me why ?
> 
> sizeof( foo ) returns 5  when I use the gcc : why is this ? could someone
> explain me why ?
> 
> Is there any option for the arm-linux-gcc to give the same result as the gcc
?
> 
> thank you
> Xavier
> 
> _______________________________________________
> http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
> 



_______________________________________________
http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm

Reply via email to