I am two C files in a project. 1. main.c 2. rtc.c and third one is header file for both in which all prototypes are defined.
I want to use a bit variables named aon and aoff in both files. Now three condition arises
1. i declare extern bit aon,aoff; in header file but it gives error
//ERROR L104: MULTIPLE PUBLIC DEFINITIONSERROR L104: MULTIPLE PUBLIC DEFINITIONSERROR L104: MULTIPLE PUBLIC DEFINITIONSextern bit aon=0,aoff=0;
2. i declare extern bit aon,aoff; in onlyin main file but it gives error
aon and aoff not declared in rtc; and vice versa
3. i declare in both c files than again i gives error
Why?
i declare
Actually, no, you didn't, because this
extern bit aon,aoff;
is not what you actully wrote. You defined those variables instead:
extern bit aon=0,aoff=0;
Pick up your C textbook and read up on the difference between a definition and a declaration. If you don't have a textbook, it's high time you got one.
Very nice.
Thanks i was not aware of this. Problem is solved.