Reputation: 575
I use the __DATE__
macro for getting a compile-time year:
const QString build_year = __DATE__ + 7;
The Clang Code Model in QtCreator throws a -Wdate-time
warning for using the __DATE__
macro.
warning: expansion of date or time macro is not reproducible
I can disable this warning with -Wno-date-time
, but what is wrong with using __DATE__
?
What is an "expansion" of the macro, how can it be "reproducible" or "not reproducible", and why is "not reproducible" bad?
Upvotes: 22
Views: 5579
Reputation: 31465
The warning message tells you why. Using the macro does not result in a reproducible build since its value will change over time. A build in 2018 and one in 2019 will not produce the same binary.
Upvotes: 6
Reputation: 1869
Having repeated builds reproduce binary-identical outputs is desirable from many points of view. Building identical source code from identical tool chains giving different binaries each time could hide serious problems.
If you don't need to produce identical binaries every time you build identical code just disable that warning. that's why the command-line switch exists.
Upvotes: 45