I’m working on a shared library that has some header files which contain function templates like:
#ifdef somecompilerflag
#define FUNCTION functionA
#else
#define FUNCTION functionB
#endif
void FUNCTION( ... );
The somecompilerflag is something defined when compiling my library. However, if someone else wants to link to this library, I don’t want them to have to pick up my compiler flags when including these header files. Is there a way to resolve these #ifdefs when compiling the library, so that a resulting header file would look something like:
void functionA( ... );
There was an answer here earlier that alluded to this approach, which is if the
somecompilerflagis defined, when “compiling” the header file (actually copying to another directory) insert#define somecompilerflagat the top of the file. For the makefile, something along the lines of: