Just out of curiosity I am wondering whether the value given by the standard __TIME__
preprocessor macro can change within a single translation unit?
In other words, is __TIME__
determined once during preprocessing and then fixed, or is it re-evaluated each time it is encountered?
If this is not specified by the C standard, is there a de facto standard behavior among the major implementations (gnu, clang, intel, msvc)?
The C preprocessor is a macro preprocessor (allows you to define macros) that transforms your program before it is compiled. These transformations can be the inclusion of header files, macro expansions, etc.
Predefined Macros in C99 standard:It is used to test whether a header is compiled by a C compiler or a C++ compiler. This macro gives value similar to __STDC_VERSION__, in that it expands to a version number.
C does not rigorously specify the the " time of translation" is constant throughout a pre-processing/compilation.
My experience has been it is constant. But since it is only to the second, a given compilation would need to cross a second boundary to differ.
__TIME__
The time of translation of the preprocessing translation unit: a character string literal of the form"hh:mm:ss"
as in the time generated by theasctime
function. If the time of translation is not available, an implementation-defined valid time shall be supplied. C11 §6.10.8.1 1The definitions for
__DATE__
and__TIME__
when respectively, the date and time of translation are not available (6.10.8.1). (Informative) C11 §J.3.11 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With