Guys,
How can I declare a bit variable defined in a file as "extern" when that variable is defined in another file?
Although in the page 99 (C51, uVision2, V2.38) describes that I should be able to put:
extern bit mybit0;
I already have defined previously in a global file:
int bdata ibase; sbit mybit0 = ibase ^ 0;
But yet, I receive this error message:
File (line xx): error C231: 'mybit0': redefinition
What I am missing? Is there any other way to declare a "dbata" variable and declare its bits for usage in multiple files?
Both files are in the project. If I create a large single file with all my code (and all the variable declarations - no extern) I do not get any error message.
Please be gentle and specific in you answers, so I can understand your wisdom.
Thanks in advanced,
dB
Hi guys,
I just tried to emulate what this sections said:
http://www.keil.com/support/man/docs/c51/c51_le_bitaddrobj.htm
However, for some reasons I cannot do it, since all my extern bit variables are later spit out by the program with the error message C231: "variable redefinition"
The following compiles for me with no errors, no warnings:
main.c
extern bit flag_0; extern void set_flag_0( void ); extern void clear_flag_0( void ); unsigned char bdata flags; sbit flag_0 = flags^0; void main( void ) { set_flag_0(); clear_flag_0(); }
other.c
extern bit flag_0; void set_flag_0( void ) { flag_0 = 1; } void clear_flag_0( void ) { flag_0 = 0; }
Result:
Build target 'Target 1' compiling main.c... compiling other.c... linking... Program Size: data=10.0 xdata=0 code=27 "bits" - 0 Error(s), 0 Warning(s).