I would like to override a macro from the command line. Somewhere in my source, there is a definition like this:
#define MY_FOO 1
What I would like is to set the value of this macro when I compile my program:
g++ -DMY_FOO=2 ...
But then, the macro is redefined by the source code to its old value 1. The problem is that I don't own the part of the source that defines the macro in the first place. If it were my own code, I could simply write
#ifndef MY_FOO
#define MY_FOO 1
#endif
And my problem would be gone. So is there way to specify a macro on the command line using g++ so that the source code cannot redefine it?
#undef
it after your#include
?