[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] can't compile simple test.c
From: |
Gregory Berardi |
Subject: |
Re: [avr-gcc-list] can't compile simple test.c |
Date: |
24 Aug 2003 22:32:26 -0500 |
You're right. I had seen that output and didn't realize it meant that
it was the stack pointer. The original code used SP and I hadn't tried
another variable name, I thought it was very unconventional to use an
uppercase variable name. IAR must not define SP as the stack pointer.
Changing SP to sp fixed it.
Thanks for your help.
-greg
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.
-Groucho Marx
On Sun, 2003-08-24 at 15:17, Christian Vogel wrote:
> Hi Gregory,
>
> > If I add -E to the CFLAGS, as suggested by Joerg Wunsch so that I may
> > see the preprocessor output, the code compiles and I get no errors but
> > the linker doesn't recognize the file format of the object file.
>
> Of course. Because the linker wants to link object files... and by using
> -E you are giving him C-Code :-)
>
> So if you convert yout test.c to the preprocessor output-file (test.e)
> with this command:
>
> avr-gcc -g -Os -mmcu=atmega103 -I/usr/local/avr/include/ -E -o test.E
> test.c
>
> you will notice, that the line where the compiler complains:
>
> float foo(float SP);
>
> was converted after the pre-processor did his work (look at test.E) to:
>
> float foo(float (*(volatile unsigned int *)((0x3D) + 0x20)));
>
> this is, because SP is defined to be a macro for the stack pointer (which
> in avr's unified memory/register space is at address 0x3D+0x20!
>
> If you rename all SP-variables to, for example, _SP, your code compiles!
>
> Chris