Structure alignment problem

Richard Earnshaw rearnsha@arm.com
Sat Nov 2 07:26:00 GMT 2002


> Does some know why I get this with GCC 2.95.3 (arm-elf) ?
> 
> typedef struct {
>     unsigned char Var1 __attribute__((packed)) ;
> } mystruct;
> 
> sizeof(mystruct) = 4 !!
> 
>
Because you need to pack the structure as a whole, not just the members of 
it.

Try

typedef struct {
    unsigned char Var1;
} mystruct __attribute__((packed));

R.


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com



More information about the crossgcc mailing list