I'm having trouble with a global variable being defined in a header file and hen being called from two different .C files. The linker is not happy. I had Codewarrior autogenerate the MCUinit.c file and have use a global variable in one of the interrupt service routines in MCUinit.c. I'd like to use this global variable in main.c. The global is defined in a header I call extras.h, complete with guards:
#define MAX_COUNT 10000
int Count_GLOBAL = 1;
#endif // __EXTRAS_H
I call #include "extras.h" from both MCUinit.c and main.c but the linker is telling me
Link Error: L1818: Symbol 16 - Count_GLOBAL duplicated in MCUinit.c.o and main.c.o.
When I remove the #include call in either MCUinit.c or main.c the compiler complains that the variable is not declared.
Does anyone know a way around this?