The key must contain variable declarations in the header file and the source file.
I use this trick
------sample.c------ #define sample_c #include sample.h (rest of sample .c) ------sample.h------ #ifdef sample_c #define EXTERN #else #define EXTERN extern #endif EXTERN int x;
Sample.c compiles only once and defines the variables. Any file that includes sample.h only gets the "extern" variable; it allocates space for this variable.
When you change type x, it will change for everyone. You will not need to change it in the source file and the header file.
Robert Jul 22 '09 at 13:37 2009-07-22 13:37
source share