273 lines
14 KiB
Markdown
273 lines
14 KiB
Markdown
[cpp.predefined]
|
||
|
||
# 15 Preprocessing directives [[cpp]](./#cpp)
|
||
|
||
## 15.12 Predefined macro names [cpp.predefined]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2173)
|
||
|
||
The following macro names shall be defined by the implementation:
|
||
|
||
- [(1.1)](#1.1)
|
||
|
||
__cplusplus
|
||
The integer literal 202302L[.](#1.1.sentence-2)
|
||
[*Note [1](#note-1)*:
|
||
Future revisions of this document will
|
||
replace the value of this macro with a greater value[.](#1.1.sentence-3)
|
||
â *end note*]
|
||
|
||
- [(1.2)](#1.2)
|
||
|
||
The names listed in Table [22](#tab:cpp.predefined.ft "Table 22: Feature-test macros")[.](#1.2.sentence-1)
|
||
|
||
The macros defined in Table [22](#tab:cpp.predefined.ft "Table 22: Feature-test macros") shall be defined to
|
||
the corresponding integer literal[.](#1.2.sentence-2)
|
||
[*Note [2](#note-2)*:
|
||
Future revisions of this document might replace
|
||
the values of these macros with greater values[.](#1.2.sentence-3)
|
||
â *end note*]
|
||
|
||
- [(1.3)](#1.3)
|
||
|
||
__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 theasctime function,
|
||
and the first character ofdd is a space character if the value is less than 10[.](#1.3.sentence-2)
|
||
If the date of translation is not available,
|
||
an implementation-defined valid date
|
||
shall be supplied[.](#1.3.sentence-3)
|
||
|
||
- [(1.4)](#1.4)
|
||
|
||
__FILE__
|
||
The presumed name of the current source file (a character string
|
||
literal)[.](#1.4.sentence-2)[129](#footnote-129 "The presumed source file name can be changed by the #line directive.")
|
||
|
||
- [(1.5)](#1.5)
|
||
|
||
__LINE__
|
||
The presumed line number (within the current source file) of the current source line
|
||
(an integer literal)[.](#1.5.sentence-2)[130](#footnote-130 "The presumed line number can be changed by the #line directive.")
|
||
|
||
- [(1.6)](#1.6)
|
||
|
||
__STDC_EMBED_NOT_FOUND__, __STDC_EMBED_FOUND__, and __STDC_EMBED_EMPTY__
|
||
The integer literals 0, 1, and 2, respectively[.](#1.6.sentence-2)
|
||
[*Note [3](#note-3)*:
|
||
These represent values replaced from [*has-embed-expression*](cpp.cond#nt:has-embed-expression "15.2 Conditional inclusion [cpp.cond]")*s* ([[cpp.cond]](cpp.cond "15.2 Conditional inclusion"))[.](#1.6.sentence-3)
|
||
â *end note*]
|
||
|
||
- [(1.7)](#1.7)
|
||
|
||
__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]](intro.compliance "4.1 Implementation compliance"))[.](#1.7.sentence-2)
|
||
|
||
- [(1.8)](#1.8)
|
||
|
||
__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)[.](#1.8.sentence-2)
|
||
[*Note [4](#note-4)*:
|
||
Larger alignments will be passed tooperator new(std::size_t, std::align_val_t), etc[.](#1.8.sentence-3)
|
||
([[expr.new]](expr.new "7.6.2.8 New"))[.](#1.8.sentence-4)
|
||
â *end note*]
|
||
|
||
- [(1.9)](#1.9)
|
||
|
||
__STDCPP_FLOAT16_T__
|
||
Defined as the integer literal 1 if and only if the implementation supports
|
||
the ISO/IEC 60559 floating-point interchange format binary16
|
||
as an extended floating-point type ([[basic.extended.fp]](basic.extended.fp "6.9.3 Optional extended floating-point types"))[.](#1.9.sentence-2)
|
||
|
||
- [(1.10)](#1.10)
|
||
|
||
__STDCPP_FLOAT32_T__
|
||
Defined as the integer literal 1 if and only if the implementation supports
|
||
the ISO/IEC 60559 floating-point interchange format binary32
|
||
as an extended floating-point type[.](#1.10.sentence-2)
|
||
|
||
- [(1.11)](#1.11)
|
||
|
||
__STDCPP_FLOAT64_T__
|
||
Defined as the integer literal 1 if and only if the implementation supports
|
||
the ISO/IEC 60559 floating-point interchange format binary64
|
||
as an extended floating-point type[.](#1.11.sentence-2)
|
||
|
||
- [(1.12)](#1.12)
|
||
|
||
__STDCPP_FLOAT128_T__
|
||
Defined as the integer literal 1 if and only if the implementation supports
|
||
the ISO/IEC 60559 floating-point interchange format binary128
|
||
as an extended floating-point type[.](#1.12.sentence-2)
|
||
|
||
- [(1.13)](#1.13)
|
||
|
||
__STDCPP_BFLOAT16_T__
|
||
Defined as the integer literal 1 if and only if the implementation supports an extended floating-point type
|
||
with the properties of the [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]") std::bfloat16_t as described in [[basic.extended.fp]](basic.extended.fp "6.9.3 Optional extended floating-point types")[.](#1.13.sentence-2)
|
||
|
||
- [(1.14)](#1.14)
|
||
|
||
__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 theasctime function[.](#1.14.sentence-2)
|
||
If the time of translation is not available,
|
||
an implementation-defined valid time shall be supplied[.](#1.14.sentence-3)
|
||
|
||
Table [22](#tab:cpp.predefined.ft) — Feature-test macros [[tab:cpp.predefined.ft]](./tab:cpp.predefined.ft)
|
||
|
||
| [ð](#tab:cpp.predefined.ft-row-1)<br>**Macro name** | **Value** |
|
||
| --- | --- |
|
||
| [ð](#tab:cpp.predefined.ft-row-2)<br>__cpp_aggregate_bases | 201603L |
|
||
| [ð](#tab:cpp.predefined.ft-row-3)<br>__cpp_aggregate_nsdmi | 201304L |
|
||
| [ð](#tab:cpp.predefined.ft-row-4)<br>__cpp_aggregate_paren_init | 201902L |
|
||
| [ð](#tab:cpp.predefined.ft-row-5)<br>__cpp_alias_templates | 200704L |
|
||
| [ð](#tab:cpp.predefined.ft-row-6)<br>__cpp_aligned_new | 201606L |
|
||
| [ð](#tab:cpp.predefined.ft-row-7)<br>__cpp_attributes | 200809L |
|
||
| [ð](#tab:cpp.predefined.ft-row-8)<br>__cpp_auto_cast | 202110L |
|
||
| [ð](#tab:cpp.predefined.ft-row-9)<br>__cpp_binary_literals | 201304L |
|
||
| [ð](#tab:cpp.predefined.ft-row-10)<br>__cpp_capture_star_this | 201603L |
|
||
| [ð](#tab:cpp.predefined.ft-row-11)<br>__cpp_char8_t | 202207L |
|
||
| [ð](#tab:cpp.predefined.ft-row-12)<br>__cpp_concepts | 202002L |
|
||
| [ð](#tab:cpp.predefined.ft-row-13)<br>__cpp_conditional_explicit | 201806L |
|
||
| [ð](#tab:cpp.predefined.ft-row-14)<br>__cpp_constexpr | 202406L |
|
||
| [ð](#tab:cpp.predefined.ft-row-15)<br>__cpp_constexpr_dynamic_alloc | 201907L |
|
||
| [ð](#tab:cpp.predefined.ft-row-16)<br>__cpp_constexpr_exceptions | 202411L |
|
||
| [ð](#tab:cpp.predefined.ft-row-17)<br>__cpp_constexpr_in_decltype | 201711L |
|
||
| [ð](#tab:cpp.predefined.ft-row-18)<br>__cpp_constexpr_virtual_inheritance | 202506L |
|
||
| [ð](#tab:cpp.predefined.ft-row-19)<br>__cpp_consteval | 202211L |
|
||
| [ð](#tab:cpp.predefined.ft-row-20)<br>__cpp_constinit | 201907L |
|
||
| [ð](#tab:cpp.predefined.ft-row-21)<br>__cpp_contracts | 202502L |
|
||
| [ð](#tab:cpp.predefined.ft-row-22)<br>__cpp_decltype | 200707L |
|
||
| [ð](#tab:cpp.predefined.ft-row-23)<br>__cpp_decltype_auto | 201304L |
|
||
| [ð](#tab:cpp.predefined.ft-row-24)<br>__cpp_deduction_guides | 201907L |
|
||
| [ð](#tab:cpp.predefined.ft-row-25)<br>__cpp_delegating_constructors | 200604L |
|
||
| [ð](#tab:cpp.predefined.ft-row-26)<br>__cpp_deleted_function | 202403L |
|
||
| [ð](#tab:cpp.predefined.ft-row-27)<br>__cpp_designated_initializers | 201707L |
|
||
| [ð](#tab:cpp.predefined.ft-row-28)<br>__cpp_enumerator_attributes | 201411L |
|
||
| [ð](#tab:cpp.predefined.ft-row-29)<br>__cpp_expansion_statements | 202506L |
|
||
| [ð](#tab:cpp.predefined.ft-row-30)<br>__cpp_explicit_this_parameter | 202110L |
|
||
| [ð](#tab:cpp.predefined.ft-row-31)<br>__cpp_fold_expressions | 201603L |
|
||
| [ð](#tab:cpp.predefined.ft-row-32)<br>__cpp_generic_lambdas | 201707L |
|
||
| [ð](#tab:cpp.predefined.ft-row-33)<br>__cpp_guaranteed_copy_elision | 201606L |
|
||
| [ð](#tab:cpp.predefined.ft-row-34)<br>__cpp_hex_float | 201603L |
|
||
| [ð](#tab:cpp.predefined.ft-row-35)<br>__cpp_if_consteval | 202106L |
|
||
| [ð](#tab:cpp.predefined.ft-row-36)<br>__cpp_if_constexpr | 201606L |
|
||
| [ð](#tab:cpp.predefined.ft-row-37)<br>__cpp_impl_coroutine | 201902L |
|
||
| [ð](#tab:cpp.predefined.ft-row-38)<br>__cpp_impl_destroying_delete | 201806L |
|
||
| [ð](#tab:cpp.predefined.ft-row-39)<br>__cpp_impl_three_way_comparison | 201907L |
|
||
| [ð](#tab:cpp.predefined.ft-row-40)<br>__cpp_impl_reflection | 202506L |
|
||
| [ð](#tab:cpp.predefined.ft-row-41)<br>__cpp_implicit_move | 202207L |
|
||
| [ð](#tab:cpp.predefined.ft-row-42)<br>__cpp_inheriting_constructors | 201511L |
|
||
| [ð](#tab:cpp.predefined.ft-row-43)<br>__cpp_init_captures | 201803L |
|
||
| [ð](#tab:cpp.predefined.ft-row-44)<br>__cpp_initializer_lists | 200806L |
|
||
| [ð](#tab:cpp.predefined.ft-row-45)<br>__cpp_inline_variables | 201606L |
|
||
| [ð](#tab:cpp.predefined.ft-row-46)<br>__cpp_lambdas | 200907L |
|
||
| [ð](#tab:cpp.predefined.ft-row-47)<br>__cpp_modules | 201907L |
|
||
| [ð](#tab:cpp.predefined.ft-row-48)<br>__cpp_multidimensional_subscript | 202211L |
|
||
| [ð](#tab:cpp.predefined.ft-row-49)<br>__cpp_named_character_escapes | 202207L |
|
||
| [ð](#tab:cpp.predefined.ft-row-50)<br>__cpp_namespace_attributes | 201411L |
|
||
| [ð](#tab:cpp.predefined.ft-row-51)<br>__cpp_noexcept_function_type | 201510L |
|
||
| [ð](#tab:cpp.predefined.ft-row-52)<br>__cpp_nontype_template_args | 201911L |
|
||
| [ð](#tab:cpp.predefined.ft-row-53)<br>__cpp_nontype_template_parameter_auto | 201606L |
|
||
| [ð](#tab:cpp.predefined.ft-row-54)<br>__cpp_nsdmi | 200809L |
|
||
| [ð](#tab:cpp.predefined.ft-row-55)<br>__cpp_pack_indexing | 202311L |
|
||
| [ð](#tab:cpp.predefined.ft-row-56)<br>__cpp_placeholder_variables | 202306L |
|
||
| [ð](#tab:cpp.predefined.ft-row-57)<br>__cpp_pp_embed | 202502L |
|
||
| [ð](#tab:cpp.predefined.ft-row-58)<br>__cpp_range_based_for | 202211L |
|
||
| [ð](#tab:cpp.predefined.ft-row-59)<br>__cpp_raw_strings | 200710L |
|
||
| [ð](#tab:cpp.predefined.ft-row-60)<br>__cpp_ref_qualifiers | 200710L |
|
||
| [ð](#tab:cpp.predefined.ft-row-61)<br>__cpp_return_type_deduction | 201304L |
|
||
| [ð](#tab:cpp.predefined.ft-row-62)<br>__cpp_rvalue_references | 200610L |
|
||
| [ð](#tab:cpp.predefined.ft-row-63)<br>__cpp_size_t_suffix | 202011L |
|
||
| [ð](#tab:cpp.predefined.ft-row-64)<br>__cpp_sized_deallocation | 201309L |
|
||
| [ð](#tab:cpp.predefined.ft-row-65)<br>__cpp_static_assert | 202306L |
|
||
| [ð](#tab:cpp.predefined.ft-row-66)<br>__cpp_static_call_operator | 202207L |
|
||
| [ð](#tab:cpp.predefined.ft-row-67)<br>__cpp_structured_bindings | 202411L |
|
||
| [ð](#tab:cpp.predefined.ft-row-68)<br>__cpp_template_parameters | 202502L |
|
||
| [ð](#tab:cpp.predefined.ft-row-69)<br>__cpp_template_template_args | 201611L |
|
||
| [ð](#tab:cpp.predefined.ft-row-70)<br>__cpp_threadsafe_static_init | 200806L |
|
||
| [ð](#tab:cpp.predefined.ft-row-71)<br>__cpp_trivial_relocatability | 202502L |
|
||
| [ð](#tab:cpp.predefined.ft-row-72)<br>__cpp_trivial_union | 202502L |
|
||
| [ð](#tab:cpp.predefined.ft-row-73)<br>__cpp_unicode_characters | 200704L |
|
||
| [ð](#tab:cpp.predefined.ft-row-74)<br>__cpp_unicode_literals | 200710L |
|
||
| [ð](#tab:cpp.predefined.ft-row-75)<br>__cpp_user_defined_literals | 200809L |
|
||
| [ð](#tab:cpp.predefined.ft-row-76)<br>__cpp_using_enum | 201907L |
|
||
| [ð](#tab:cpp.predefined.ft-row-77)<br>__cpp_variable_templates | 201304L |
|
||
| [ð](#tab:cpp.predefined.ft-row-78)<br>__cpp_variadic_friend | 202403L |
|
||
| [ð](#tab:cpp.predefined.ft-row-79)<br>__cpp_variadic_templates | 200704L |
|
||
| [ð](#tab:cpp.predefined.ft-row-80)<br>__cpp_variadic_using | 201611L |
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2405)
|
||
|
||
The following macro names are conditionally defined by the implementation:
|
||
|
||
- [(2.1)](#2.1)
|
||
|
||
__STDC__
|
||
Whether __STDC__ is predefined and if so, what its value is,
|
||
are implementation-defined[.](#2.1.sentence-2)
|
||
|
||
- [(2.2)](#2.2)
|
||
|
||
__STDC_MB_MIGHT_NEQ_WC__
|
||
The integer literal 1, intended to indicate that, in the encoding forwchar_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[.](#2.2.sentence-2)
|
||
|
||
- [(2.3)](#2.3)
|
||
|
||
__STDC_VERSION__
|
||
Whether __STDC_VERSION__ is predefined and if so, what its value is,
|
||
are implementation-defined[.](#2.3.sentence-2)
|
||
|
||
- [(2.4)](#2.4)
|
||
|
||
__STDC_ISO_10646__
|
||
An integer literal of the form yyyymmL (for example, 199712L)[.](#2.4.sentence-2)
|
||
Whether __STDC_ISO_10646__ is predefined and
|
||
if so, what its value is,
|
||
are implementation-defined[.](#2.4.sentence-3)
|
||
|
||
- [(2.5)](#2.5)
|
||
|
||
__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 "6.10.2 Multi-threaded executions and data races [intro.multithread]")[.](#2.5.sentence-2)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2443)
|
||
|
||
The values of the predefined macros
|
||
(except for__FILE__ and__LINE__)
|
||
remain constant throughout the translation unit[.](#3.sentence-1)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2451)
|
||
|
||
If any of the pre-defined macro names in this subclause,
|
||
or the identifierdefined,
|
||
is the subject of a#define or a#undef preprocessing directive,
|
||
the program is ill-formed[.](#4.sentence-1)
|
||
|
||
Any other predefined macro names shall begin with a
|
||
leading underscore followed by an uppercase letter or a second
|
||
underscore[.](#4.sentence-2)
|
||
|
||
[129)](#footnote-129)[129)](#footnoteref-129)
|
||
|
||
The presumed source file name can be changed by the #line directive[.](#footnote-129.sentence-1)
|
||
|
||
[130)](#footnote-130)[130)](#footnoteref-130)
|
||
|
||
The presumed line number can be changed by the #line directive[.](#footnote-130.sentence-1)
|