15 Preprocessing directives [cpp]

15.11 Predefined macro names [cpp.predefined]

The following macro names shall be defined by the implementation:
  • __cplusplus
    The integer literal 202002L.
    [Note 1:
    Future revisions of C++ will replace the value of this macro with a greater value.
    — end note]
  • The names listed in Table 19.

    The macros defined in Table 19 shall be defined to the corresponding integer literal.
    [Note 2:
    Future revisions of C++ might replace the values of these macros with greater values.
    — end note]
  • __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).154
  • __LINE__
    The presumed line number (within the current source file) of the current source line (an integer literal).155
  • __STDC_­HOSTED__
    The integer literal 1 if the implementation is a hosted implementation or the integer literal 0 if it is a freestanding implementation ([intro.compliance]).
  • __STDCPP_­DEFAULT_­NEW_­ALIGNMENT__
    An integer literal of type std​::​size_­t whose value is the alignment guaranteed by a call to operator new(std​::​size_­t) or operator new[](std​::​size_­t).
    [Note 3:
    Larger alignments will be passed to operator new(std​::​size_­t, std​::​align_­val_­t), etc.
    — end note]
  • __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.
Table 19: Feature-test macros [tab:cpp.predefined.ft]
Macro name
Value
__cpp_­aggregate_­bases
201603L
__cpp_­aggregate_­nsdmi
201304L
__cpp_­aggregate_­paren_­init
201902L
__cpp_­alias_­templates
200704L
__cpp_­aligned_­new
201606L
__cpp_­attributes
200809L
__cpp_­binary_­literals
201304L
__cpp_­capture_­star_­this
201603L
__cpp_­char8_­t
201811L
__cpp_­concepts
201907L
__cpp_­conditional_­explicit
201806L
__cpp_­constexpr
201907L
__cpp_­constexpr_­dynamic_­alloc
201907L
__cpp_­constexpr_­in_­decltype
201711L
__cpp_­consteval
201811L
__cpp_­constinit
201907L
__cpp_­decltype
200707L
__cpp_­decltype_­auto
201304L
__cpp_­deduction_­guides
201907L
__cpp_­delegating_­constructors
200604L
__cpp_­designated_­initializers
201707L
__cpp_­enumerator_­attributes
201411L
__cpp_­fold_­expressions
201603L
__cpp_­generic_­lambdas
201707L
__cpp_­guaranteed_­copy_­elision
201606L
__cpp_­hex_­float
201603L
__cpp_­if_­constexpr
201606L
__cpp_­impl_­coroutine
201902L
__cpp_­impl_­destroying_­delete
201806L
__cpp_­impl_­three_­way_­comparison
201907L
__cpp_­inheriting_­constructors
201511L
__cpp_­init_­captures
201803L
__cpp_­initializer_­lists
200806L
__cpp_­inline_­variables
201606L
__cpp_­lambdas
200907L
__cpp_­modules
201907L
__cpp_­namespace_­attributes
201411L
__cpp_­noexcept_­function_­type
201510L
__cpp_­nontype_­template_­args
201911L
__cpp_­nontype_­template_­parameter_­auto
201606L
__cpp_­nsdmi
200809L
__cpp_­range_­based_­for
201603L
__cpp_­raw_­strings
200710L
__cpp_­ref_­qualifiers
200710L
__cpp_­return_­type_­deduction
201304L
__cpp_­rvalue_­references
200610L
__cpp_­sized_­deallocation
201309L
__cpp_­static_­assert
201411L
__cpp_­structured_­bindings
201606L
__cpp_­template_­template_­args
201611L
__cpp_­threadsafe_­static_­init
200806L
__cpp_­unicode_­characters
200704L
__cpp_­unicode_­literals
200710L
__cpp_­user_­defined_­literals
200809L
__cpp_­using_­enum
201907L
__cpp_­variable_­templates
201304L
__cpp_­variadic_­templates
200704L
__cpp_­variadic_­using
201611L
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 code point 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.
  • __STDCPP_­THREADS__
    Defined, and has the value integer literal 1, if and only if a program can have more than one thread of execution.
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.
154)154)
The presumed source file name can be changed by the #line directive.
155)155)
The presumed line number can be changed by the #line directive.