First I'd like to point out that the structure is kinda bad, so if you wanna flame me for it please don't .
Anyway, consider 3 files:
a.h:
(yes, that's a function definition in the header!)Code:#ifndef A_H #define A_H void Func() { ... } #endif
b.cpp:
c.cpp:Code:#include "a.h"
b.cpp and c.cpp are compiled as separate modules then linked together. Now, even with inclusion guards in a.h the function will be defined in both files thus causing conflicts when linking b and c together.Code:#include "a.h"
I know I have a definition in the header file which I in all other cases would NOT do, but in this particular scenario it is required.
Is this solveable, to only get it defined once in one module? Or solve it in any other way? Since the modules are separately compiled the inclusion guards doesn't work well.