16 Preprocessing directives [cpp]

16.8 Predefined macro names [cpp.predefined]

The following macro names shall be defined by the implementation:

  • __cplusplus
    The name  __cplusplus is defined to the value 201402L when compiling a C++ translation unit.157

  • __DATE__
    The date of translation of the source file: a character string literal of the form "Mmm dd yyyy", where the names of the months are the same as those generated by the asctime function, and the first character of dd is a space character if the value is less than 10. If the date of translation is not available, an implementation-defined valid date shall be supplied.

  • __FILE__
    The presumed name of the current source file (a character string literal).158

  • __LINE__
    The presumed line number (within the current source file) of the current source line (an integer literal).footnote-1159

  • __STDC_HOSTED__
    The integer literal 1 if the implementation is a hosted implementation or the integer literal 0 if it is not.

  • __TIME__
    The time of translation of the source file: a character string literal of the form "hh:mm:ss" as in the time generated by the asctime function. If the time of translation is not available, an implementation-defined valid time shall be supplied.

The following macro names are conditionally defined by the implementation:

  • __STDC__
    Whether __STDC__ is predefined and if so, what its value is, are implementation-defined.

  • __STDC_MB_MIGHT_NEQ_WC__
    The integer literal 1, intended to indicate that, in the encoding for wchar_t, a member of the basic character set need not have a code value equal to its value when used as the lone character in an ordinary character literal.

  • __STDC_VERSION__
    Whether __STDC_VERSION__ is predefined and if so, what its value is, are implementation-defined.

  • __STDC_ISO_10646__
    An integer literal of the form yyyymmL (for example, 199712L). If this symbol is defined, then every character in the Unicode required set, when stored in an object of type wchar_t, has the same value as the short identifier of that character. The Unicode required set consists of all the characters that are defined by ISO/IEC 10646, along with all amendments and technical corrigenda as of the specified year and month.

  • __STDCPP_STRICT_POINTER_SAFETY__
    Defined, and has the value integer literal 1, if and only if the implementation has strict pointer safety ([basic.stc.dynamic.safety]).

  • __STDCPP_THREADS__
    Defined, and has the value integer literal 1, if and only if a program can have more than one thread of execution ([intro.multithread]).

The values of the predefined macros (except for __FILE__ and __LINE__) remain constant throughout the translation unit.

If any of the pre-defined macro names in this subclause, or the identifier defined, is the subject of a #define or a #undef preprocessing directive, the behavior is undefined. Any other predefined macro names shall begin with a leading underscore followed by an uppercase letter or a second underscore.

It is intended that future versions of this standard will replace the value of this macro with a greater value. Non-conforming compilers should use a value with at most five decimal digits.

The presumed source file name and line number can be changed by the #line directive.