I have an include file with 100+ global variables. It's being used in a library, but some programs that I'm linking the lib to also need to access the globals.
The way it was built:
// In one library .c file
#define Extern
// In the programs that use the globals
#define Extern extern
// In the .h file
Extern int a,b,c;
I had a hard time understanding why the original programmer did that so I removed that define Extern stuff. Now I think I understand the thing about TU with the help of stackoverflow: 1, 2, 3.
Now I understand that I should define the global variables in one .c file in the library and use extern in the .h file. The problem is that I don't want to duplicate code.
Should I go back to that #define Extern voodoo?