Both C and C++ provide the following
predefined macro names as specified in the ISO C language standard. Except for
__FILE__ and
__LINE__,
the value of the predefined macros remains constant throughout the
translation unit.
- __DATE__
- A character string literal containing the date when the source
file was compiled.
The value of
__DATE__ changes
as the compiler processes any include files that are part of your
source program. The date is in the form:
"Mmm dd yyyy"
where:
- Mmm
- Represents the month in an abbreviated form (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
or Dec).
- dd
- Represents the day. If the day is less than 10, the first d is
a blank character.
- yyyy
- Represents the year.
- __FILE__
- A character string literal containing the name of the source file.
The value of __FILE__ changes as the compiler
processes include files that are part of your source program. It can
be set with the #line directive.
- __LINE__
- An integer representing the current source line number.
The
value of __LINE__ changes during compilation as the
compiler processes subsequent lines of your source program. It can
be set with the #line directive.
- __STDC__
- For C, the integer 1 (one) indicates that the C compiler supports
the ISO standard. If you set the language level to classic,
this macro is undefined. (When a macro is undefined, it behaves
as if it had the integer value 0 when used in a #if statement.)
For C++, this macro is predefined to have the
value 0 (zero). This indicates that the C++ language is not a proper
superset of C, and that the compiler does not conform to ISO C.
- __STDC_HOSTED__ (C only)
- The value of this C99 macro is 1, indicating that the C compiler
is a hosted implementation. Note that this macro is only defined
if __STDC__ is also defined.
- __STDC_VERSION__ (C only)
- The integer constant of type long int: 199409L
for the C89 language level, 199901L for C99. Note that this macro
is only defined if __STDC__ is also defined.
- __TIME__
- A character string literal containing the time when the source
file was compiled.
The value of
__TIME__ changes
as the compiler processes any include files that are part of your
source program. The time is in the form:
"hh:mm:ss"
where:
- hh
- Represents the hour.
- mm
- Represents the minutes.
- ss
- Represents the seconds.
- __cplusplus (C++ only)
- For C++ programs, this macro expands to the long integer literal
199711L, indicating that the compiler is a C++ compiler. For C programs,
this macro is not defined. Note that this macro name has no trailing
underscores.