Hi Kurt,

It looks like you found a bug. The reason it only 
complains about the flag in main is because it's 
optimized away in test. Somehow SDCC forgets to allocate 
the space for the local bit variable. If you make it 
static or volatile it does get an address. And as you 
found out also when it's global. Would you be so kind to 
report it in our bugtracker system?

Greetings,
Maarten



> I'm running sdcc V2.9.2 on Windows XP from build 
> sdcc-20090817-5492-setup.exe.
> 
> When I define a bit variable in a function, compile functions separately, 
> then link together I get a linker warning that the global variable 
> referenced by the module is undefined.
> 
> ?ASlink-Warning-Undefined Global '_FOO_VARIABLENAME_1_1' referenced by 
> module 'FOO'
> 
> I have a main application.  mainApp.c, along with a subordinate 
> application myFoo.c  compiled in DOS using;
> sdcc -mmcs51 --model-small --iram-size 256 -I C:\SDCC\Include -c mainApp.c
> sdcc -mmcs51 --model-small --iram-size 256 -I C:\SDCC\Include -c myFoo.c
> 
> then link using:
> sdcc -mmcs51 --model-small --iram-size 256 ^
> --code-loc 0x0500 --stack-loc 0x0080 --xram-loc 0x3000 ^
> -L C:\SDCC\MyCode\EZ-USB_Lib -l EZUSB -I C:\SDCC\Include ^
> mainApp.rel myFoo.rel
> 
> myFoo.rel will contain a function such as:
> 
> bit myFunction( void) 
> {
>         bit myFlag;
> 
>         myFlag = TRUE;
>         return(myFlag);
> }
> 
> unfortunately the above code worked and didn't exhibit the same issue. The 
> main failed though.
> 
> // Function prototype.
> bit myFunction( void);
> 
> void main(void)
> {
>    bit myFlag;
>    unsigned char tempByte;
> 
>    myFlag = myFunction();
> }
> 
> gives me a linker error ?ASlink-Warning-Undefined Global 
> '_main_myFlag_1_1' referenced by module 'fw'  Here my main is in fw.c.
> 
> I suppose I could stop using bit variables as flags in functions.  Or make 
> them all globals.  But the sdccman appears to support local bit functions 
> too.
> 
> I also question if its a bseg size issue?  I'm using the Cypress CY7C68013 
> with 16 8-bit bit addressable registers.  Will the linker support that or 
> think that I've only got 16 bits available?  That might explain why some 
> of the time it may work depending upon when it assigns the bit address.
> 
> Any help is appreciated.
> 
> 



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to