Is there any possibility to redefine __DATE__ and __TIME__ predefined C++ macros (give them other than default values) in Microsoft Visual Studio?
I tried compiler option /D "__DATE__=\"Feb 10 2021\"" but I'm getting:
pch.cpp : warning C4117: macro name '__DATE__' is reserved, '#define' ignored
and no effect. Any idea except modification of the code (or a confirmation 'it is not possible')?
Reason: C++ project, that I have, has its builds versioned by date macro values (every build gets its version from __DATE__/__TIME__ values). I need to simulate an "older" build - basically, to cheat this versioning system. I don't need to change the macro value format. I also know about an option to have another user-defined macro mentioned by @Jabberwocky.
#undef __DATE__and#undef __TIME__to undefine a macro so you can give it a different value.Jabberwockys answear./uto undefine Microsoft-specific symbols that the compiler defines, see learn.microsoft.com/en-us/cpp/build/reference/… (I'm not sure if it works with standard macros like__DATE__or only with additions made by MSVC).