avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] -fpacked-struct compiler option


From: E. Weddington
Subject: Re: [avr-gcc-list] -fpacked-struct compiler option
Date: Fri, 07 Jan 2005 09:56:03 -0700
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

Anton Erasmus wrote:

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)


Thanks for doing this test!
But at least it doesn't hurt to have the switch explicity on the command line. Unless otherwise, it'll probably stay in the WinAVR Makefile template. For paranoia's sake. :-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]