Hi,
I ran the following commands on the test code below:
(Lates WinAVR version)
avr-gcc -c test1.c -Os -funsigned-char -funsigned-bitfields -fpack-struct
-fshort-enums -
Wall -Wstrict-prototypes -Wa,-ahlms=test_s.lst
avr-gcc -c test1.c -O1 -funsigned-char -funsigned-bitfields -fpack-struct
-fshort-enums -
Wall -Wstrict-prototypes -Wa,-ahlms=test_1.lst
avr-gcc -c test1.c -O2 -funsigned-char -funsigned-bitfields -fpack-struct
-fshort-enums -
Wall -Wstrict-prototypes -Wa,-ahlms=test_2.lst
avr-gcc -c test1.c -O3 -funsigned-char -funsigned-bitfields -fpack-struct
-fshort-enums -
Wall -Wstrict-prototypes -Wa,-ahlms=test_3.lst
avr-gcc -c test1.c -Os -funsigned-char -funsigned-bitfields -fshort-enums
-Wall -
Wstrict-prototypes -Wa,-ahlms=test1_s.lst
avr-gcc -c test1.c -O1 -funsigned-char -funsigned-bitfields -fshort-enums
-Wall -
Wstrict-prototypes -Wa,-ahlms=test1_1.lst
avr-gcc -c test1.c -O2 -funsigned-char -funsigned-bitfields -fshort-enums
-Wall -
Wstrict-prototypes -Wa,-ahlms=test1_2.lst
avr-gcc -c test1.c -O3 -funsigned-char -funsigned-bitfields -fshort-enums
-Wall -
Wstrict-prototypes -Wa,-ahlms=test1_3.lst
typedef struct
{
unsigned char c;
unsigned long L;
unsigned char b[4];
}test_t;
test_t foo;
void bar(void)
{
volatile unsigned char xx;
volatile unsigned long xxx;
volatile int i;
xx=foo.c;
xxx=foo.L;
i=sizeof(foo);
}
It generates exactely the same code in all cases with no 4 or 2 byte alignment visible
even without the -fpack-struct option. So it appeard as if the -fpack-struct is redundent
for the avr. ( On arm-elf-gcc it generates extremely non-optimal code when
using this
option)