It not only makes access inefficient, it can also cause more trouble, especially if you use arrays of structs. The compiler might then generate word-access to aligned fields (if aligned inside the original struct) which point to an odd address (since the struct now might have an odd length). This results in every second struct in the array being accessed wrong without notice (the processor just ignores the LSB in word operations, while the compiler 'thinks' everything is well when doing word access to odd adresses)
I had a lot of trouble with this when working with stacked data packages which are transmitted from MSP to ATmega and X86 systems. I ended up storing everything in byte elements (INT and LONG stored in char[x] fields and read/set with macros). JMGross ----- Ursprüngliche Nachricht ----- Von: Sergey A. Borshch An: GCC for MSP430 - http://mspgcc.sf.net Gesendet am: 19.Mai.2009 00:42:11 Betreff: Re: [Mspgcc-users] Struct size [email protected] wrote: > Thank you for the tip. > I found the (quite easy) solution: > > -fpack-struct solves the problem. But it makes access to multi-byte fields inefficient (byte-by-byte).
