In a C file file.c I have
#define STUFF
I want a Makefile so that I can prevent STUFF from being defined in file.c. I want to control the compilation using only the Makefile (and I do not want to comment out the line in the .c file directly).
gcc has the -D option. I can do
gcc -D STUFF file.c -o output
for defining STUFF; but I cannot Undefine STUFF invoking gcc or using the Makefile (with gcc invoked in the Makefile of course).
Any hint ?
-U
. However, this only undefines values which are already defined at that point, either built-in or from the command line: it doesn't take precedence over things that will later be defined in various files. So if you use-DFOO -UFOO
thenFOO
is not defined. But you can't undefine something that's#define
d in a source file from the command line. It would be nice if-U
worked like an override and ensured that all attempts to#define
that macro in the source would be ignored. But it doesn't. – MadScientist Mar 13 '14 at 18:10