avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] Strange struct problem


From: Russell Shaw
Subject: Re: [avr-chat] Strange struct problem
Date: Fri, 09 Dec 2005 11:22:54 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.11) Gecko/20050914 Debian/1.7.11-1

Daniel O'Connor wrote:
Hi,
I am getting this odd problem with structs. If the size of the struct is larger than 4 bytes I can't access it.. It's most peculiar.

I have a test case (attached).

Build it with..
avr-gcc -O2 -fno-strict-aliasing -pipe  -g -Wall -Wunreachable-code 
-DF_CPU=16000000 -mmcu=atmega32 -Wa,-adhlmsn=testcase.lst -c testcase.c -o 
testcase.o
avr-gcc -O2 -fno-strict-aliasing -pipe -g -Wall -Wunreachable-code -DF_CPU=16000000 -mmcu=atmega32 -Wl,-Map=testcase.map,--cref -g testcase.o -o testcase.elf avr-objcopy -j .text -O ihex testcase.elf testcase.hex
avr-objdump -S testcase.elf > testcase.dmp

If BREAKME is defined all the struct accesses return 255 instead of what
they should be (I think :)

I am wondering if there is some oddity with GCC optimising for <= 4 byte
structs which unbreaks my code, but I can't see why it is broken.

Any help gratefully received!

Beware of structure padding leaving holes.

http://www.eskimo.com/~scs/C-faq/q2.12.html
http://www.eskimo.com/~scs/C-faq/q2.13.html




reply via email to

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