In a project where the __FILE__
and __DATE__
macros are used in one of the modules, I am trying to redefine the values of these macros to explicit values during build time. Trying to use the -D
option, like -D__TIME__=01:23:45
gave me a compilation error.
Compiling ./Console.c
In file included from <built-in>:324:
<command line>:41:9: error: redefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
#define __TIME__ 01:23:45
^
1 error generated.
Is there a way to set these macros (and similar predefined macros) from the command line, w/o altering the source code itself?
Compile with the switch
-Wno-builtin-macro-redefined
.That will disable the warning (including the error you get because you are also compiling with
-Werror
). I cannot assure you what it will do with the macro definition—Clang appears to be obeying the request to use the command-line definition, but I do not know it will do so in all circumstances.