Hi,

while ok in this case (with variables being pinned to fixed locations), please never put variable definitions into header files, even if guarded by such defines. Sooner or later you will end up getting linker errors, which someone could then try to resolve by making the variables static, which leads to duplication of the variables and interesting errors at runtime.

For variable declarations in header files, you need to use the extern keyword!

Best regards,
Raphael

On Jun 21, 2014 10:45 PM, "Joel Davidson" <jrd@prismnet.com> wrote:
On Sat, 21 Jun 2014, it would appear that Kustaa Nyholm wrote:

> On 18/06/2014 16:41, "Maarten Brock" <sourceforge.brock@dse.nl> wrote:
>>
>> I don't know. I don't work on the pic backend. But try it and you'll find
>> out soon enough I guess by looking at the generated asm.
>
> Maybe I should have tried this first...
>
>
> In the .h I put:
>
> extern volatile BDT ep0_o;
>
>
> In the .c that includes above I put:
>
> volatile BDT __at (0x0400+0*8) ep0_o;
>
> and the compiler says:
>
> usb_pic_defs.c:9: error 91: extern definition for 'ep0_o' mismatches with
> declaration.
> usb_pic_defs.h:70: error 177: previously defined here
>
>
> So...maybe I'm too tired but I can't figure out how I can put a
> variable at a given address and declare it in the .h file
> and define it in the .c file. If I define it at the .h file
> then I get into trouble with linker if I include the .h file
> in multiple .c files...not god.
>
> br Kusti

Why not put:

#ifndef __VARDEF
volatile BDT __at (0x0400+0*8) ep0_o;
#define __VARDEF
#endif
...other defines

in your .h?

Joel
--
Joel Davidson
Austin, TX

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user