Hello together,
I'm coding a simple UART-Application on the MCBSTM32 eval board and have problems with the preprocessor directives. I studied the whole documentation here and I'm pretty sure I'm coding in a common way, but still I can't compile my program. These are the very first lines of my main header file:
#ifndef ___MAIN_H_ #define ___MAIN_H_ #endif #undef EX #ifndef ___MAIN_C_ #define EX extern #else #define EX #endif
And my variables a coded that way:
EX unsigned int ui_TxFrameCounter;
When compiling the program, I get the error code "L6200E: symbol multiply defined" for my variables, because of including the header to other files. I want to declare the variables "extern" for the other header files. Could somebody help me? Would be nice. Geetings
Like this ("include guard" omitted for clarity):
The header file contains only straightforward extern declarations:
// main.h extern char tom; extern int ***; extern long harry;
main.c contains the definitions and includes the header:
// main.c #include "main.h" char tom; int ***; long harry;
Including the header here is important - it's what allows the compiler to detect any discrepancies!
Other .c files just include the header:
// other.c #include "main.h" // code can reference tom, ***, and/or harry...
Again, see: c-faq.com/.../decldef.html
If you still want to pursue the preprocessor business, the first thing to do is to examine the preprocessor output - see Andy's Handy Hint for Debugging Preprocessor Problems here: www.8052.com/.../read.phtml (it is not specific to 8052).