From Jason Turner

[cpp]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpkh_s32k7/{from.md → to.md} +749 -191
tmp/tmpkh_s32k7/{from.md → to.md} RENAMED
@@ -39,10 +39,11 @@ group-part:
39
 
40
  ``` bnf
41
  control-line:
42
  '# include' pp-tokens new-line
43
  pp-import
 
44
  '# define ' identifier replacement-list new-line
45
  '# define ' identifier lparen identifier-listₒₚₜ ')' replacement-list new-line
46
  '# define ' identifier lparen '... )' replacement-list new-line
47
  '# define ' identifier lparen identifier-list ', ... )' replacement-list new-line
48
  '# undef ' identifier new-line
@@ -65,12 +66,11 @@ if-group:
65
  '# ifndef ' identifier new-line groupₒₚₜ
66
  ```
67
 
68
  ``` bnf
69
  elif-groups:
70
- elif-group
71
- elif-groups elif-group
72
  ```
73
 
74
  ``` bnf
75
  elif-group:
76
  '# elif ' constant-expression new-line groupₒₚₜ
@@ -114,39 +114,86 @@ replacement-list:
114
  pp-tokensₒₚₜ
115
  ```
116
 
117
  ``` bnf
118
  pp-tokens:
119
- preprocessing-token
120
- pp-tokens preprocessing-token
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  ```
122
 
123
  ``` bnf
124
  new-line:
125
  the new-line character
126
  ```
127
 
 
 
 
 
 
 
128
  A *preprocessing directive* consists of a sequence of preprocessing
129
  tokens that satisfies the following constraints: At the start of
130
- translation phase 4, the first token in the sequence, referred to as a
131
- *directive-introducing token*, begins with the first character in the
132
- source file (optionally after whitespace containing no new-line
133
- characters) or follows whitespace containing at least one new-line
134
- character, and is
135
 
136
  - a `#` preprocessing token, or
137
  - an `import` preprocessing token immediately followed on the same
138
- logical line by a *header-name*, `<`, *identifier*, *string-literal*,
139
- or `:` preprocessing token, or
140
  - a `module` preprocessing token immediately followed on the same
141
- logical line by an *identifier*, `:`, or `;` preprocessing token, or
 
142
  - an `export` preprocessing token immediately followed on the same
143
- logical line by one of the two preceding forms.
144
 
145
- The last token in the sequence is the first token within the sequence
146
- that is immediately followed by whitespace containing a new-line
147
- character.[^1]
148
 
149
  [*Note 1*: A new-line character ends the preprocessing directive even
150
  if it occurs within what would otherwise be an invocation of a
151
  function-like macro. — *end note*]
152
 
@@ -176,15 +223,38 @@ import -> // not a preprocessing directive
176
  ```
177
 
178
  — *end example*]
179
 
180
  A sequence of preprocessing tokens is only a *text-line* if it does not
181
- begin with a directive-introducing token. A sequence of preprocessing
182
- tokens is only a *conditionally-supported-directive* if it does not
183
- begin with any of the directive names appearing after a `#` in the
184
- syntax. A *conditionally-supported-directive* is conditionally-supported
185
- with *implementation-defined* semantics.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
 
187
  At the start of phase 4 of translation, the *group* of a
188
  *pp-global-module-fragment* shall contain neither a *text-line* nor a
189
  *pp-import*.
190
 
@@ -193,24 +263,18 @@ relaxed to allow any sequence of preprocessing tokens to occur between
193
  the directive name and the following new-line character.
194
 
195
  The only whitespace characters that shall appear between preprocessing
196
  tokens within a preprocessing directive (from just after the
197
  directive-introducing token through just before the terminating new-line
198
- character) are space and horizontal-tab (including spaces that have
199
- replaced comments or possibly other whitespace characters in translation
200
- phase 3).
201
-
202
- The implementation can process and skip sections of source files
203
- conditionally, include other source files, import macros from header
204
- units, and replace macros. These capabilities are called
205
- *preprocessing*, because conceptually they occur before translation of
206
- the resulting translation unit.
207
 
208
  The preprocessing tokens within a preprocessing directive are not
209
  subject to macro expansion unless otherwise stated.
210
 
211
- [*Example 2*:
212
 
213
  In:
214
 
215
  ``` cpp
216
  #define EMPTY
@@ -237,12 +301,11 @@ h-preprocessing-token:
237
  any *preprocessing-token* other than '>'
238
  ```
239
 
240
  ``` bnf
241
  h-pp-tokens:
242
- h-preprocessing-token
243
- h-pp-tokens h-preprocessing-token
244
  ```
245
 
246
  ``` bnf
247
  header-name-tokens:
248
  string-literal
@@ -253,79 +316,104 @@ header-name-tokens:
253
  has-include-expression:
254
  '__has_include' '(' header-name ')'
255
  '__has_include' '(' header-name-tokens ')'
256
  ```
257
 
 
 
 
 
 
 
258
  ``` bnf
259
  has-attribute-expression:
260
  '__has_cpp_attribute (' pp-tokens ')'
261
  ```
262
 
263
  The expression that controls conditional inclusion shall be an integral
264
  constant expression except that identifiers (including those lexically
265
  identical to keywords) are interpreted as described below[^2]
266
 
267
- and it may contain zero or more *defined-macro-expression*s and/or
268
- *has-include-expression*s and/or *has-attribute-expression*s as unary
269
- operator expressions.
 
 
270
 
271
  A *defined-macro-expression* evaluates to `1` if the identifier is
272
  currently defined as a macro name (that is, if it is predefined or if it
273
  has one or more active macro definitions [[cpp.import]], for example
274
  because it has been the subject of a `#define` preprocessing directive
275
  without an intervening `#undef` directive with the same subject
276
  identifier), `0` if it is not.
277
 
278
- The second form of *has-include-expression* is considered only if the
279
- first form does not match, in which case the preprocessing tokens are
280
- processed just as in normal text.
281
-
282
  The header or source file identified by the parenthesized preprocessing
283
  token sequence in each contained *has-include-expression* is searched
284
- for as if that preprocessing token sequence were the *pp-tokens* in a
285
  `#include` directive, except that no further macro expansion is
286
- performed. If such a directive would not satisfy the syntactic
287
- requirements of a `#include` directive, the program is ill-formed. The
 
288
  *has-include-expression* evaluates to `1` if the search for the source
289
  file succeeds, and to `0` if the search fails.
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  Each *has-attribute-expression* is replaced by a non-zero *pp-number*
292
  matching the form of an *integer-literal* if the implementation supports
293
  an attribute with the name specified by interpreting the *pp-tokens*,
294
  after macro expansion, as an *attribute-token*, and by `0` otherwise.
295
  The program is ill-formed if the *pp-tokens* do not match the form of an
296
  *attribute-token*.
297
 
298
- For an attribute specified in this document, the value of the
299
- *has-attribute-expression* is given by [[cpp.cond.ha]]. For other
300
- attributes recognized by the implementation, the value is
 
301
  *implementation-defined*.
302
 
303
- [*Note 1*: It is expected that the availability of an attribute can be
304
  detected by any non-zero result. — *end note*]
305
 
306
  **Table: __has_cpp_attribute values** <a id="cpp.cond.ha">[cpp.cond.ha]</a>
307
 
308
  | Attribute | Value |
309
- | -------------------- | --------- |
310
  | `assume` | `202207L` |
311
- | `carries_dependency` | `200809L` |
312
  | `deprecated` | `201309L` |
313
  | `fallthrough` | `201603L` |
 
314
  | `likely` | `201803L` |
315
  | `maybe_unused` | `201603L` |
316
  | `no_unique_address` | `201803L` |
317
  | `nodiscard` | `201907L` |
318
  | `noreturn` | `200809L` |
319
  | `unlikely` | `201803L` |
320
 
321
 
322
  The `#ifdef`, `#ifndef`, `#elifdef`, and `#elifndef` directives, and the
323
- `defined` conditional inclusion operator, shall treat `__has_include`
324
- and `__has_cpp_attribute` as if they were the names of defined macros.
325
- The identifiers `__has_include` and `__has_cpp_attribute` shall not
326
- appear in any context not mentioned in this subclause.
 
327
 
328
  Each preprocessing token that remains (in the list of preprocessing
329
  tokens that will become the controlling expression) after all macro
330
  replacements have occurred shall be in the lexical form of a token
331
  [[lex.token]].
@@ -340,44 +428,50 @@ Preprocessing directives of the forms
340
  check whether the controlling constant expression evaluates to nonzero.
341
 
342
  Prior to evaluation, macro invocations in the list of preprocessing
343
  tokens that will become the controlling constant expression are replaced
344
  (except for those macro names modified by the `defined` unary operator),
345
- just as in normal text. If the token `defined` is generated as a result
346
- of this replacement process or use of the `defined` unary operator does
347
- not match one of the two specified forms prior to macro replacement, the
348
- behavior is undefined.
 
 
 
 
 
 
349
 
350
  After all replacements due to macro expansion and evaluations of
351
- *defined-macro-expression*s, *has-include-expression*s, and
352
- *has-attribute-expression*s have been performed, all remaining
353
- identifiers and keywords, except for `true` and `false`, are replaced
354
- with the *pp-number* `0`, and then each preprocessing token is converted
355
- into a token.
356
 
357
- [*Note 2*: An alternative token [[lex.digraph]] is not an identifier,
358
  even when its spelling consists entirely of letters and underscores.
359
  Therefore it is not subject to this replacement. — *end note*]
360
 
361
  The resulting tokens comprise the controlling constant expression which
362
  is evaluated according to the rules of  [[expr.const]] using arithmetic
363
  that has at least the ranges specified in  [[support.limits]]. For the
364
  purposes of this token conversion and evaluation all signed and unsigned
365
  integer types act as if they have the same representation as,
366
  respectively, `intmax_t` or `uintmax_t` [[cstdint.syn]].
367
 
368
- [*Note 3*: Thus on an implementation where
369
  `std::numeric_limits<int>::max()` is `0x7FFF` and
370
  `std::numeric_limits<unsigned int>::max()` is `0xFFFF`, the integer
371
  literal `0x8000` is signed and positive within a `#if` expression even
372
  though it is unsigned in translation phase 7
373
  [[lex.phases]]. — *end note*]
374
 
375
  This includes interpreting *character-literal*s according to the rules
376
  in [[lex.ccon]].
377
 
378
- [*Note 4*: The associated character encodings of literals are the same
379
  in `#if` and `#elif` directives and in any expression. — *end note*]
380
 
381
  Each subexpression with type `bool` is subjected to integral promotion
382
  before processing continues.
383
 
@@ -395,20 +489,20 @@ name. Their conditions are equivalent to `#if` `defined` *identifier*,
395
  `#if` `!defined` *identifier*, `#elif` `defined` *identifier*, and
396
  `#elif` `!defined` *identifier*, respectively.
397
 
398
  Each directive’s condition is checked in order. If it evaluates to false
399
  (zero), the group that it controls is skipped: directives are processed
400
- only through the name that determines the directive in order to keep
401
- track of the level of nested conditionals; the rest of the directives’
402
- preprocessing tokens are ignored, as are the other preprocessing tokens
403
- in the group. Only the first group whose control condition evaluates to
404
- true (nonzero) is processed; any following groups are skipped and their
405
- controlling directives are processed as if they were in a group that is
406
- skipped. If none of the conditions evaluates to true, and there is a
407
- `#else` directive, the group controlled by the `#else` is processed;
408
- lacking a `#else` directive, all the groups until the `#endif` are
409
- skipped.[^3]
410
 
411
  [*Example 1*:
412
 
413
  This demonstrates a way to include a library `optional` facility only if
414
  it is available:
@@ -449,61 +543,80 @@ ATTR_DEPRECATED("This function is deprecated") void anvil();
449
 
450
  — *end example*]
451
 
452
  ## Source file inclusion <a id="cpp.include">[[cpp.include]]</a>
453
 
454
- A `#include` directive shall identify a header or source file that can
455
- be processed by the implementation.
 
 
456
 
457
- A preprocessing directive of the form
458
-
459
- ``` bnf
460
- '# include <' h-char-sequence '>' new-line
461
- ```
462
-
463
- searches a sequence of *implementation-defined* places for a header
464
- identified uniquely by the specified sequence between the `<` and `>`
465
- delimiters, and causes the replacement of that directive by the entire
466
- contents of the header. How the places are specified or the header
467
- identified is *implementation-defined*.
468
 
469
  A preprocessing directive of the form
470
 
471
  ``` bnf
472
- '# include "' q-char-sequence '"' new-line
473
  ```
474
 
475
  causes the replacement of that directive by the entire contents of the
476
- source file identified by the specified sequence between the `"`
477
- delimiters. The named source file is searched for in an
478
- *implementation-defined* manner. If this search is not supported, or if
479
- the search fails, the directive is reprocessed as if it read
 
 
 
 
 
 
 
 
480
 
481
  ``` bnf
482
- '# include <' h-char-sequence '>' new-line
483
  ```
484
 
485
- with the identical contained sequence (including `>` characters, if any)
486
- from the original directive.
 
 
 
 
 
 
 
 
487
 
488
  A preprocessing directive of the form
489
 
490
  ``` bnf
491
  '# include' pp-tokens new-line
492
  ```
493
 
494
- (that does not match one of the two previous forms) is permitted. The
495
- preprocessing tokens after `include` in the directive are processed just
496
- as in normal text (i.e., each identifier currently defined as a macro
497
- name is replaced by its replacement list of preprocessing tokens). If
498
- the directive resulting after all replacements does not match one of the
499
- two previous forms, the behavior is undefined.[^4]
 
 
 
 
 
500
 
501
- The method by which a sequence of preprocessing tokens between a `<` and
502
- a `>` preprocessing token pair or a pair of `"` characters is combined
503
- into a single header name preprocessing token is
504
- *implementation-defined*.
505
 
506
  The implementation shall provide unique mappings for sequences
507
  consisting of one or more *nondigit*s or *digit*s [[lex.name]] followed
508
  by a period (`.`) and a single *nondigit*. The first character shall not
509
  be a *digit*. The implementation may ignore distinctions of alphabetical
@@ -517,14 +630,14 @@ If the header identified by the *header-name* denotes an importable
517
  header [[module.import]], it is *implementation-defined* whether the
518
  `#include` preprocessing directive is instead replaced by an `import`
519
  directive [[cpp.import]] of the form
520
 
521
  ``` bnf
522
- 'import' header-name ';' new-line
523
  ```
524
 
525
- [*Note 1*:
526
 
527
  An implementation can provide a mechanism for making arbitrary source
528
  files available to the `< >` search. However, using the `< >` form for
529
  headers provided with the implementation and the `" "` form for sources
530
  outside the control of the implementation achieves wider portability.
@@ -554,20 +667,418 @@ This illustrates macro-replaced `#include` directives:
554
  #include INCFILE
555
  ```
556
 
557
  — *end example*]
558
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  ## Module directive <a id="cpp.module">[[cpp.module]]</a>
560
 
561
  ``` bnf
562
  pp-module:
563
  exportₒₚₜ module pp-tokensₒₚₜ ';' new-line
564
  ```
565
 
566
  A *pp-module* shall not appear in a context where `module` or (if it is
567
- the first token of the *pp-module*) `export` is an identifier defined as
568
- an object-like macro.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
 
570
  Any preprocessing tokens after the `module` preprocessing token in the
571
  `module` directive are processed just as in normal text.
572
 
573
  [*Note 1*: Each identifier currently defined as a macro name is
@@ -588,12 +1099,12 @@ pp-import:
588
  exportₒₚₜ import header-name-tokens pp-tokensₒₚₜ ';' new-line
589
  exportₒₚₜ import pp-tokens ';' new-line
590
  ```
591
 
592
  A *pp-import* shall not appear in a context where `import` or (if it is
593
- the first token of the *pp-import*) `export` is an identifier defined as
594
- an object-like macro.
595
 
596
  The preprocessing tokens after the `import` preprocessing token in the
597
  `import` *control-line* are processed just as in normal text (i.e., each
598
  identifier currently defined as a macro name is replaced by its
599
  replacement list of preprocessing tokens).
@@ -654,11 +1165,11 @@ translation unit and at most one point of undefinition, as follows:
654
  unit is the first point at which a `#undef` directive naming the macro
655
  occurs after its point of definition, or the first point of macro
656
  import of a header unit containing a point of undefinition for the
657
  macro definition, whichever (if any) occurs first.
658
 
659
- A macro directive is *active* at a source location if it has a point of
660
  definition in that translation unit preceding the location, and does not
661
  have a point of undefinition in that translation unit preceding the
662
  location.
663
 
664
  If a macro would be replaced or redefined, and multiple macro
@@ -791,10 +1302,16 @@ The identifier immediately following the `define` is called the *macro
791
  name*. There is one name space for macro names. Any whitespace
792
  characters preceding or following the replacement list of preprocessing
793
  tokens are not considered part of the replacement list for either form
794
  of macro.
795
 
 
 
 
 
 
 
796
  If a `#` preprocessing token, followed by an identifier, occurs
797
  lexically at the point at which a preprocessing directive can begin, the
798
  identifier is not subject to macro replacement.
799
 
800
  A preprocessing directive of the form
@@ -802,17 +1319,17 @@ A preprocessing directive of the form
802
  ``` bnf
803
  '# define' identifier replacement-list new-line
804
  ```
805
 
806
  defines an *object-like macro* that causes each subsequent instance of
807
- the macro name[^5]
808
 
809
  to be replaced by the replacement list of preprocessing tokens that
810
- constitute the remainder of the directive.[^6]
811
 
812
  The replacement list is then rescanned for more macro names as specified
813
- below.
814
 
815
  [*Example 2*:
816
 
817
  The simplest use of this facility is to define a “manifest constant”, as
818
  in
@@ -848,13 +1365,13 @@ The sequence of preprocessing tokens bounded by the outside-most
848
  matching parentheses forms the list of arguments for the function-like
849
  macro. The individual arguments within the list are separated by comma
850
  preprocessing tokens, but comma preprocessing tokens between matching
851
  inner parentheses do not separate arguments. If there are sequences of
852
  preprocessing tokens within the list of arguments that would otherwise
853
- act as preprocessing directives,[^7]
854
 
855
- the behavior is undefined.
856
 
857
  [*Example 3*:
858
 
859
  The following defines a function-like macro whose value is the maximum
860
  of its arguments. It has the disadvantages of evaluating one or the
@@ -888,22 +1405,22 @@ va-opt-replacement:
888
 
889
  After the arguments for the invocation of a function-like macro have
890
  been identified, argument substitution takes place. For each parameter
891
  in the replacement list that is neither preceded by a `#` or `##`
892
  preprocessing token nor followed by a `##` preprocessing token, the
893
- preprocessing tokens naming the parameter are replaced by a token
894
- sequence determined as follows:
895
 
896
  - If the parameter is of the form *va-opt-replacement*, the replacement
897
  preprocessing tokens are the preprocessing token sequence for the
898
  corresponding argument, as specified below.
899
  - Otherwise, the replacement preprocessing tokens are the preprocessing
900
  tokens of corresponding argument after all macros contained therein
901
  have been expanded. The argument’s preprocessing tokens are completely
902
  macro replaced before being substituted as if they formed the rest of
903
- the preprocessing file with no other preprocessing tokens being
904
- available.
905
 
906
  [*Example 1*:
907
 
908
  ``` cpp
909
  #define LPAREN() (
@@ -1019,17 +1536,21 @@ argument’s preprocessing tokens becomes a single space character in the
1019
  character string literal. Whitespace before the first preprocessing
1020
  token and after the last preprocessing token comprising the stringizing
1021
  argument is deleted. Otherwise, the original spelling of each
1022
  preprocessing token in the stringizing argument is retained in the
1023
  character string literal, except for special handling for producing the
1024
- spelling of *string-literal*s and *character-literal*s: a `\` character
1025
- is inserted before each `"` and `\` character of a *character-literal*
1026
- or *string-literal* (including the delimiting `"` characters). If the
1027
- replacement that results is not a valid character string literal, the
1028
- behavior is undefined. The character string literal corresponding to an
1029
- empty stringizing argument is `""`. The order of evaluation of `#` and
1030
- `##` operators is unspecified.
 
 
 
 
1031
 
1032
  ### The `##` operator <a id="cpp.concat">[[cpp.concat]]</a>
1033
 
1034
  A `##` preprocessing token shall not occur at the beginning or at the
1035
  end of a replacement list for either form of macro definition.
@@ -1037,31 +1558,29 @@ end of a replacement list for either form of macro definition.
1037
  If, in the replacement list of a function-like macro, a parameter is
1038
  immediately preceded or followed by a `##` preprocessing token, the
1039
  parameter is replaced by the corresponding argument’s preprocessing
1040
  token sequence; however, if an argument consists of no preprocessing
1041
  tokens, the parameter is replaced by a placemarker preprocessing token
1042
- instead.[^8]
1043
 
1044
  For both object-like and function-like macro invocations, before the
1045
  replacement list is reexamined for more macro names to replace, each
1046
  instance of a `##` preprocessing token in the replacement list (not from
1047
  an argument) is deleted and the preceding preprocessing token is
1048
  concatenated with the following preprocessing token. Placemarker
1049
  preprocessing tokens are handled specially: concatenation of two
1050
  placemarkers results in a single placemarker preprocessing token, and
1051
  concatenation of a placemarker with a non-placemarker preprocessing
1052
- token results in the non-placemarker preprocessing token. If the result
1053
- begins with a sequence matching the syntax of
1054
- *universal-character-name*, the behavior is undefined.
1055
 
1056
- [*Note 1*: This determination does not consider the replacement of
1057
- *universal-character-name*s in translation phase 3
1058
- [[lex.phases]]. — *end note*]
1059
 
1060
- If the result is not a valid preprocessing token, the behavior is
1061
- undefined. The resulting token is available for further macro
1062
- replacement. The order of evaluation of `##` operators is unspecified.
 
1063
 
1064
  [*Example 1*:
1065
 
1066
  The sequence
1067
 
@@ -1102,12 +1621,12 @@ fputs("strncmp(\"abc\\0d\", \"abc\", '\\4') == 0: \@n", s);
1102
  #include "vers2.h" (after macro replacement, before file access)
1103
  "hello";
1104
  "hello, world"
1105
  ```
1106
 
1107
- Space around the `#` and `##` tokens in the macro definition is
1108
- optional.
1109
 
1110
  — *end example*]
1111
 
1112
  [*Example 2*:
1113
 
@@ -1129,13 +1648,13 @@ in_between(x hash_hash y)
1129
  in_between(x ## y)
1130
  mkstr(x ## y)
1131
  "x ## y"
1132
  ```
1133
 
1134
- In other words, expanding `hash_hash` produces a new token, consisting
1135
- of two adjacent sharp signs, but this new token is not the `##`
1136
- operator.
1137
 
1138
  — *end example*]
1139
 
1140
  [*Example 3*:
1141
 
@@ -1237,13 +1756,15 @@ macro name.
1237
  ## Line control <a id="cpp.line">[[cpp.line]]</a>
1238
 
1239
  The *string-literal* of a `#line` directive, if present, shall be a
1240
  character string literal.
1241
 
1242
- The *line number* of the current source line is one greater than the
1243
- number of new-line characters read or introduced in translation phase 1
1244
- [[lex.phases]] while processing the source file to the current token.
 
 
1245
 
1246
  A preprocessing directive of the form
1247
 
1248
  ``` bnf
1249
  '# line' digit-sequence new-line
@@ -1251,11 +1772,11 @@ A preprocessing directive of the form
1251
 
1252
  causes the implementation to behave as if the following sequence of
1253
  source lines begins with a source line that has a line number as
1254
  specified by the digit sequence (interpreted as a decimal integer). If
1255
  the digit sequence specifies zero or a number greater than 2147483647,
1256
- the behavior is undefined.
1257
 
1258
  A preprocessing directive of the form
1259
 
1260
  ``` bnf
1261
  '# line' digit-sequence '"' s-char-sequenceₒₚₜ '"' new-line
@@ -1273,25 +1794,33 @@ A preprocessing directive of the form
1273
  (that does not match one of the two previous forms) is permitted. The
1274
  preprocessing tokens after `line` on the directive are processed just as
1275
  in normal text (each identifier currently defined as a macro name is
1276
  replaced by its replacement list of preprocessing tokens). If the
1277
  directive resulting after all replacements does not match one of the two
1278
- previous forms, the behavior is undefined; otherwise, the result is
1279
  processed as appropriate.
1280
 
1281
  ## Diagnostic directives <a id="cpp.error">[[cpp.error]]</a>
1282
 
1283
- A preprocessing directive of either of the following forms
1284
 
1285
  ``` bnf
1286
  '# error' pp-tokensₒₚₜ new-line
 
 
 
 
 
1287
  '# warning' pp-tokensₒₚₜ new-line
1288
  ```
1289
 
1290
- causes the implementation to produce a diagnostic message that should
1291
- include the specified sequence of preprocessing tokens; the `# error`
1292
- directive renders the program ill-formed.
 
 
 
1293
 
1294
  ## Pragma directive <a id="cpp.pragma">[[cpp.pragma]]</a>
1295
 
1296
  A preprocessing directive of the form
1297
 
@@ -1321,20 +1850,20 @@ The following macro names shall be defined by the implementation:
1321
 
1322
  - **`__cplusplus`**
1323
 
1324
  The integer literal `202302L`.
1325
 
1326
- [*Note 1*: Future revisions of C++ will replace the value of this macro
1327
- with a greater value. — *end note*]
1328
 
1329
- - **The names listed in [[cpp.predefined.ft]].**
1330
 
1331
  The macros defined in [[cpp.predefined.ft]] shall be defined to the
1332
  corresponding integer literal.
1333
 
1334
- [*Note 2*: Future revisions of C++ might replace the values of these
1335
- macros with greater values. — *end note*]
1336
 
1337
  - **`__DATE__`**
1338
 
1339
  The date of translation of the source file: a character string literal
1340
  of the form `"Mmm dd yyyy"`, where the names of the months are the same
@@ -1343,17 +1872,30 @@ as those generated by the `asctime` function, and the first character of
1343
  translation is not available, an *implementation-defined* valid date
1344
  shall be supplied.
1345
 
1346
  - **`__FILE__`**
1347
 
1348
- The presumed name of the current source file (a character string
1349
- literal).[^9]
 
 
 
1350
 
1351
  - **`__LINE__`**
1352
 
1353
- The presumed line number (within the current source file) of the current
1354
- source line (an integer literal).[^10]
 
 
 
 
 
 
 
 
 
 
1355
 
1356
  - **`__STDC_HOSTED__`**
1357
 
1358
  The integer literal `1` if the implementation is a hosted implementation
1359
  or the integer literal `0` if it is a freestanding implementation
@@ -1363,37 +1905,37 @@ or the integer literal `0` if it is a freestanding implementation
1363
 
1364
  An integer literal of type `std::size_t` whose value is the alignment
1365
  guaranteed by a call to `operator new(std::size_t)` or
1366
  `operator new[](std::size_t)`.
1367
 
1368
- [*Note 3*: Larger alignments will be passed to
1369
  `operator new(std::size_t, std::align_val_t)`, etc.
1370
  [[expr.new]]. — *end note*]
1371
 
1372
  - **`__STDCPP_FLOAT16_T__`**
1373
 
1374
  Defined as the integer literal `1` if and only if the implementation
1375
- supports the ISO/IEC/IEEE 60559 floating-point interchange format
1376
- binary16 as an extended floating-point type [[basic.extended.fp]].
1377
 
1378
  - **`__STDCPP_FLOAT32_T__`**
1379
 
1380
  Defined as the integer literal `1` if and only if the implementation
1381
- supports the ISO/IEC/IEEE 60559 floating-point interchange format
1382
- binary32 as an extended floating-point type.
1383
 
1384
  - **`__STDCPP_FLOAT64_T__`**
1385
 
1386
  Defined as the integer literal `1` if and only if the implementation
1387
- supports the ISO/IEC/IEEE 60559 floating-point interchange format
1388
- binary64 as an extended floating-point type.
1389
 
1390
  - **`__STDCPP_FLOAT128_T__`**
1391
 
1392
  Defined as the integer literal `1` if and only if the implementation
1393
- supports the ISO/IEC/IEEE 60559 floating-point interchange format
1394
- binary128 as an extended floating-point type.
1395
 
1396
  - **`__STDCPP_BFLOAT16_T__`**
1397
 
1398
  Defined as the integer literal `1` if and only if the implementation
1399
  supports an extended floating-point type with the properties of the
@@ -1421,30 +1963,36 @@ function. If the time of translation is not available, an
1421
  | `__cpp_binary_literals` | `201304L` |
1422
  | `__cpp_capture_star_this` | `201603L` |
1423
  | `__cpp_char8_t` | `202207L` |
1424
  | `__cpp_concepts` | `202002L` |
1425
  | `__cpp_conditional_explicit` | `201806L` |
1426
- | `__cpp_constexpr` | `202211L` |
 
1427
  | `__cpp_constexpr_dynamic_alloc` | `201907L` |
 
1428
  | `__cpp_constexpr_in_decltype` | `201711L` |
1429
- | `__cpp_consteval` | `202211L` |
1430
  | `__cpp_constinit` | `201907L` |
 
1431
  | `__cpp_decltype` | `200707L` |
1432
  | `__cpp_decltype_auto` | `201304L` |
1433
- | `__cpp_deduction_guides` | `201907L` |
1434
  | `__cpp_delegating_constructors` | `200604L` |
 
1435
  | `__cpp_designated_initializers` | `201707L` |
1436
  | `__cpp_enumerator_attributes` | `201411L` |
 
1437
  | `__cpp_explicit_this_parameter` | `202110L` |
1438
  | `__cpp_fold_expressions` | `201603L` |
1439
  | `__cpp_generic_lambdas` | `201707L` |
1440
  | `__cpp_guaranteed_copy_elision` | `201606L` |
1441
  | `__cpp_hex_float` | `201603L` |
1442
  | `__cpp_if_consteval` | `202106L` |
1443
  | `__cpp_if_constexpr` | `201606L` |
1444
  | `__cpp_impl_coroutine` | `201902L` |
1445
  | `__cpp_impl_destroying_delete` | `201806L` |
 
1446
  | `__cpp_impl_three_way_comparison` | `201907L` |
1447
  | `__cpp_implicit_move` | `202207L` |
1448
  | `__cpp_inheriting_constructors` | `201511L` |
1449
  | `__cpp_init_captures` | `201803L` |
1450
  | `__cpp_initializer_lists` | `200806L` |
@@ -1456,27 +2004,34 @@ function. If the time of translation is not available, an
1456
  | `__cpp_namespace_attributes` | `201411L` |
1457
  | `__cpp_noexcept_function_type` | `201510L` |
1458
  | `__cpp_nontype_template_args` | `201911L` |
1459
  | `__cpp_nontype_template_parameter_auto` | `201606L` |
1460
  | `__cpp_nsdmi` | `200809L` |
 
 
 
1461
  | `__cpp_range_based_for` | `202211L` |
1462
  | `__cpp_raw_strings` | `200710L` |
1463
  | `__cpp_ref_qualifiers` | `200710L` |
1464
  | `__cpp_return_type_deduction` | `201304L` |
1465
  | `__cpp_rvalue_references` | `200610L` |
1466
  | `__cpp_size_t_suffix` | `202011L` |
1467
  | `__cpp_sized_deallocation` | `201309L` |
1468
- | `__cpp_static_assert` | `201411L` |
1469
  | `__cpp_static_call_operator` | `202207L` |
1470
- | `__cpp_structured_bindings` | `201606L` |
 
1471
  | `__cpp_template_template_args` | `201611L` |
1472
  | `__cpp_threadsafe_static_init` | `200806L` |
 
 
1473
  | `__cpp_unicode_characters` | `200704L` |
1474
  | `__cpp_unicode_literals` | `200710L` |
1475
  | `__cpp_user_defined_literals` | `200809L` |
1476
  | `__cpp_using_enum` | `201907L` |
1477
  | `__cpp_variable_templates` | `201304L` |
 
1478
  | `__cpp_variadic_templates` | `200704L` |
1479
  | `__cpp_variadic_using` | `201611L` |
1480
 
1481
 
1482
  The following macro names are conditionally defined by the
@@ -1513,11 +2068,11 @@ can have more than one thread of execution [[intro.multithread]].
1513
  The values of the predefined macros (except for `__FILE__` and
1514
  `__LINE__`) remain constant throughout the translation unit.
1515
 
1516
  If any of the pre-defined macro names in this subclause, or the
1517
  identifier `defined`, is the subject of a `#define` or a `#undef`
1518
- preprocessing directive, the behavior is undefined. Any other predefined
1519
  macro names shall begin with a leading underscore followed by an
1520
  uppercase letter or a second underscore.
1521
 
1522
  ## Pragma operator <a id="cpp.pragma.op">[[cpp.pragma.op]]</a>
1523
 
@@ -1564,10 +2119,17 @@ LISTING( ..\listing.dir )
1564
  [basic.extended.fp]: basic.md#basic.extended.fp
1565
  [cpp]: #cpp
1566
  [cpp.concat]: #cpp.concat
1567
  [cpp.cond]: #cpp.cond
1568
  [cpp.cond.ha]: #cpp.cond.ha
 
 
 
 
 
 
 
1569
  [cpp.error]: #cpp.error
1570
  [cpp.import]: #cpp.import
1571
  [cpp.include]: #cpp.include
1572
  [cpp.line]: #cpp.line
1573
  [cpp.module]: #cpp.module
@@ -1582,18 +2144,24 @@ LISTING( ..\listing.dir )
1582
  [cpp.rescan]: #cpp.rescan
1583
  [cpp.scope]: #cpp.scope
1584
  [cpp.stringize]: #cpp.stringize
1585
  [cpp.subst]: #cpp.subst
1586
  [cstdint.syn]: support.md#cstdint.syn
 
 
1587
  [expr.const]: expr.md#expr.const
1588
  [expr.new]: expr.md#expr.new
1589
  [intro.compliance]: intro.md#intro.compliance
 
1590
  [intro.multithread]: basic.md#intro.multithread
1591
  [lex.ccon]: lex.md#lex.ccon
 
1592
  [lex.digraph]: lex.md#lex.digraph
 
1593
  [lex.key]: lex.md#lex.key
1594
  [lex.name]: lex.md#lex.name
 
1595
  [lex.phases]: lex.md#lex.phases
1596
  [lex.token]: lex.md#lex.token
1597
  [module.import]: module.md#module.import
1598
  [support.limits]: support.md#support.limits
1599
 
@@ -1610,32 +2178,22 @@ LISTING( ..\listing.dir )
1610
  [^3]: As indicated by the syntax, a preprocessing token cannot follow a
1611
  `#else` or `#endif` directive before the terminating new-line
1612
  character. However, comments can appear anywhere in a source file,
1613
  including within a preprocessing directive.
1614
 
1615
- [^4]: Note that adjacent *string-literal*s are not concatenated into a
1616
- single *string-literal* (see the translation phases in 
1617
- [[lex.phases]]); thus, an expansion that results in two
1618
- *string-literal*s is an invalid directive.
1619
-
1620
- [^5]: Since, by macro-replacement time, all *character-literal*s and
1621
  *string-literal*s are preprocessing tokens, not sequences possibly
1622
  containing identifier-like subsequences (see [[lex.phases]],
1623
  translation phases), they are never scanned for macro names or
1624
  parameters.
1625
 
1626
- [^6]: An alternative token [[lex.digraph]] is not an identifier, even
1627
  when its spelling consists entirely of letters and underscores.
1628
  Therefore it is not possible to define a macro whose name is the
1629
  same as that of an alternative token.
1630
 
1631
- [^7]: A *conditionally-supported-directive* is a preprocessing directive
1632
  regardless of whether the implementation supports it.
1633
 
1634
- [^8]: Placemarker preprocessing tokens do not appear in the syntax
1635
  because they are temporary entities that exist only within
1636
  translation phase 4.
1637
-
1638
- [^9]: The presumed source file name can be changed by the `#line`
1639
- directive.
1640
-
1641
- [^10]: The presumed line number can be changed by the `#line` directive.
 
39
 
40
  ``` bnf
41
  control-line:
42
  '# include' pp-tokens new-line
43
  pp-import
44
+ '# embed ' pp-tokens new-line
45
  '# define ' identifier replacement-list new-line
46
  '# define ' identifier lparen identifier-listₒₚₜ ')' replacement-list new-line
47
  '# define ' identifier lparen '... )' replacement-list new-line
48
  '# define ' identifier lparen identifier-list ', ... )' replacement-list new-line
49
  '# undef ' identifier new-line
 
66
  '# ifndef ' identifier new-line groupₒₚₜ
67
  ```
68
 
69
  ``` bnf
70
  elif-groups:
71
+ elif-group elif-groupsₒₚₜ
 
72
  ```
73
 
74
  ``` bnf
75
  elif-group:
76
  '# elif ' constant-expression new-line groupₒₚₜ
 
114
  pp-tokensₒₚₜ
115
  ```
116
 
117
  ``` bnf
118
  pp-tokens:
119
+ preprocessing-token pp-tokensₒₚₜ
120
+ ```
121
+
122
+ ``` bnf
123
+ embed-parameter-seq:
124
+ embed-parameter embed-parameter-seqₒₚₜ
125
+ ```
126
+
127
+ ``` bnf
128
+ embed-parameter:
129
+ embed-standard-parameter
130
+ embed-prefixed-parameter
131
+ ```
132
+
133
+ ``` bnf
134
+ embed-standard-parameter:
135
+ 'limit' '(' pp-balanced-token-seq ')'
136
+ 'prefix' '(' pp-balanced-token-seqₒₚₜ ')'
137
+ 'suffix' '(' pp-balanced-token-seqₒₚₜ ')'
138
+ 'if_empty' '(' pp-balanced-token-seqₒₚₜ ')'
139
+ ```
140
+
141
+ ``` bnf
142
+ embed-prefixed-parameter:
143
+ identifier :: identifier
144
+ identifier :: identifier '(' pp-balanced-token-seqₒₚₜ ')'
145
+ ```
146
+
147
+ ``` bnf
148
+ pp-balanced-token-seq:
149
+ pp-balanced-token pp-balanced-token-seqₒₚₜ
150
+ ```
151
+
152
+ ``` bnf
153
+ pp-balanced-token:
154
+ '(' pp-balanced-token-seqₒₚₜ ')'
155
+ '[' pp-balanced-token-seqₒₚₜ ']'
156
+ '{' pp-balanced-token-seqₒₚₜ '}'
157
+ any pp-token except:
158
+ parenthesis (U+0028 (left parenthesis) and U+0029 (right parenthesis)),
159
+ bracket (U+005b (left square bracket) and U+005d (right square bracket)), or
160
+ brace (U+007b (left curly bracket) and U+007d (right curly bracket)).
161
  ```
162
 
163
  ``` bnf
164
  new-line:
165
  the new-line character
166
  ```
167
 
168
+ The implementation can process and skip sections of source files
169
+ conditionally, include other source files, import macros from header
170
+ units, and replace macros. These capabilities are called
171
+ *preprocessing*, because conceptually they occur before translation of
172
+ the resulting translation unit.
173
+
174
  A *preprocessing directive* consists of a sequence of preprocessing
175
  tokens that satisfies the following constraints: At the start of
176
+ translation phase 4, the first preprocessing token in the sequence,
177
+ referred to as a *directive-introducing token*, begins with the first
178
+ character in the source file (optionally after whitespace containing no
179
+ new-line characters) or follows whitespace containing at least one
180
+ new-line character, and is
181
 
182
  - a `#` preprocessing token, or
183
  - an `import` preprocessing token immediately followed on the same
184
+ logical source line by a *header-name*, `<`, *identifier*,
185
+ *string-literal*, or `:` preprocessing token, or
186
  - a `module` preprocessing token immediately followed on the same
187
+ logical source line by an *identifier*, `:`, or `;` preprocessing
188
+ token, or
189
  - an `export` preprocessing token immediately followed on the same
190
+ logical source line by one of the two preceding forms.
191
 
192
+ The last preprocessing token in the sequence is the first preprocessing
193
+ token within the sequence that is immediately followed by whitespace
194
+ containing a new-line character.[^1]
195
 
196
  [*Note 1*: A new-line character ends the preprocessing directive even
197
  if it occurs within what would otherwise be an invocation of a
198
  function-like macro. — *end note*]
199
 
 
223
  ```
224
 
225
  — *end example*]
226
 
227
  A sequence of preprocessing tokens is only a *text-line* if it does not
228
+ begin with a directive-introducing token.
229
+
230
+ [*Example 2*:
231
+
232
+ ``` cpp
233
+ using module = int;
234
+ module i; // not a text-line and not a control-line
235
+ int foo() {
236
+ return i;
237
+ }
238
+ ```
239
+
240
+ The example is not a valid *preprocessing-file*.
241
+
242
+ — *end example*]
243
+
244
+ A sequence of preprocessing tokens is only a
245
+ *conditionally-supported-directive* if it does not begin with any of the
246
+ directive names appearing after a `#` in the syntax. A
247
+ *conditionally-supported-directive* is conditionally-supported with
248
+ *implementation-defined* semantics.
249
+
250
+ If one of the *pp-tokens* of a `#embed` directive (before macro
251
+ replacement) is the *identifier* `limit`, `prefix`, `suffix`, or
252
+ `if_empty` and that *identifier* is defined as a macro
253
+ [[cpp.replace.general]], the program is ill-formed. Any
254
+ *embed-prefixed-parameter* is conditionally-supported, with
255
+ *implementation-defined* semantics.
256
 
257
  At the start of phase 4 of translation, the *group* of a
258
  *pp-global-module-fragment* shall contain neither a *text-line* nor a
259
  *pp-import*.
260
 
 
263
  the directive name and the following new-line character.
264
 
265
  The only whitespace characters that shall appear between preprocessing
266
  tokens within a preprocessing directive (from just after the
267
  directive-introducing token through just before the terminating new-line
268
+ character) are U+0020 (space) and U+0009 (character tabulation)
269
+ (including spaces that have replaced comments or possibly other
270
+ whitespace characters in translation phase 3).
 
 
 
 
 
 
271
 
272
  The preprocessing tokens within a preprocessing directive are not
273
  subject to macro expansion unless otherwise stated.
274
 
275
+ [*Example 3*:
276
 
277
  In:
278
 
279
  ``` cpp
280
  #define EMPTY
 
301
  any *preprocessing-token* other than '>'
302
  ```
303
 
304
  ``` bnf
305
  h-pp-tokens:
306
+ h-preprocessing-token h-pp-tokensₒₚₜ
 
307
  ```
308
 
309
  ``` bnf
310
  header-name-tokens:
311
  string-literal
 
316
  has-include-expression:
317
  '__has_include' '(' header-name ')'
318
  '__has_include' '(' header-name-tokens ')'
319
  ```
320
 
321
+ ``` bnf
322
+ has-embed-expression:
323
+ '__has_embed' '(' header-name pp-balanced-token-seqₒₚₜ ')'
324
+ '__has_embed' '(' header-name-tokens pp-balanced-token-seqₒₚₜ ')'
325
+ ```
326
+
327
  ``` bnf
328
  has-attribute-expression:
329
  '__has_cpp_attribute (' pp-tokens ')'
330
  ```
331
 
332
  The expression that controls conditional inclusion shall be an integral
333
  constant expression except that identifiers (including those lexically
334
  identical to keywords) are interpreted as described below[^2]
335
 
336
+ and it may contain zero or more *defined-macro-expression*s,
337
+ *has-include-expression*s, *has-attribute-expression*s, and/or
338
+ *has-embed-expression*s as unary operator expressions. A
339
+ *defined-macro-expression* shall not appear within a
340
+ *has-include-expression* or *has-embed-expression*.
341
 
342
  A *defined-macro-expression* evaluates to `1` if the identifier is
343
  currently defined as a macro name (that is, if it is predefined or if it
344
  has one or more active macro definitions [[cpp.import]], for example
345
  because it has been the subject of a `#define` preprocessing directive
346
  without an intervening `#undef` directive with the same subject
347
  identifier), `0` if it is not.
348
 
 
 
 
 
349
  The header or source file identified by the parenthesized preprocessing
350
  token sequence in each contained *has-include-expression* is searched
351
+ for as if that preprocessing token sequence were the *pp-tokens* of a
352
  `#include` directive, except that no further macro expansion is
353
+ performed. If the preprocessing token sequence does not consist solely
354
+ of a *header-name* or cannot be combined [[cpp.include]] into a single
355
+ *header-name* preprocessing token, the program is ill-formed. The
356
  *has-include-expression* evaluates to `1` if the search for the source
357
  file succeeds, and to `0` if the search fails.
358
 
359
+ The parenthesized preprocessing token sequence of each contained
360
+ *has-embed-expression* is processed as if that preprocessing token
361
+ sequence were the *pp-tokens* of a `#embed` directive [[cpp.embed]],
362
+ except that no further macro expansion is performed. The
363
+ *has-embed-expression* evaluates to:
364
+
365
+ - `__STDC_EMBED_FOUND__` if the search for the resource succeeds, all
366
+ the given *embed-parameter*s in the *embed-parameter-seq* are
367
+ supported, and the resource is not empty.
368
+ - Otherwise, `__STDC_EMBED_EMPTY__` if the search for the resource
369
+ succeeds, all the given *embed-parameter*s in the
370
+ *embed-parameter-seq* are supported, and the resource is empty.
371
+ - Otherwise, `__STDC_EMBED_NOT_FOUND__`.
372
+
373
+ [*Note 1*: An unrecognized *embed-parameter* in an
374
+ *has-embed-expression* is not ill-formed and is instead treated as not
375
+ supported. — *end note*]
376
+
377
  Each *has-attribute-expression* is replaced by a non-zero *pp-number*
378
  matching the form of an *integer-literal* if the implementation supports
379
  an attribute with the name specified by interpreting the *pp-tokens*,
380
  after macro expansion, as an *attribute-token*, and by `0` otherwise.
381
  The program is ill-formed if the *pp-tokens* do not match the form of an
382
  *attribute-token*.
383
 
384
+ For an attribute specified in this document, it is
385
+ *implementation-defined* whether the value of the
386
+ *has-attribute-expression* is `0` or is given by [[cpp.cond.ha]]. For
387
+ other attributes recognized by the implementation, the value is
388
  *implementation-defined*.
389
 
390
+ [*Note 2*: It is expected that the availability of an attribute can be
391
  detected by any non-zero result. — *end note*]
392
 
393
  **Table: __has_cpp_attribute values** <a id="cpp.cond.ha">[cpp.cond.ha]</a>
394
 
395
  | Attribute | Value |
396
+ | ------------------- | --------- |
397
  | `assume` | `202207L` |
 
398
  | `deprecated` | `201309L` |
399
  | `fallthrough` | `201603L` |
400
+ | `indeterminate` | `202403L` |
401
  | `likely` | `201803L` |
402
  | `maybe_unused` | `201603L` |
403
  | `no_unique_address` | `201803L` |
404
  | `nodiscard` | `201907L` |
405
  | `noreturn` | `200809L` |
406
  | `unlikely` | `201803L` |
407
 
408
 
409
  The `#ifdef`, `#ifndef`, `#elifdef`, and `#elifndef` directives, and the
410
+ `defined` conditional inclusion operator, shall treat `__has_include`,
411
+ `__has_embed`, and `__has_cpp_attribute` as if they were the names of
412
+ defined macros. The identifiers `__has_include`, `__has_embed`, and
413
+ `__has_cpp_attribute` shall not appear in any context not mentioned in
414
+ this subclause.
415
 
416
  Each preprocessing token that remains (in the list of preprocessing
417
  tokens that will become the controlling expression) after all macro
418
  replacements have occurred shall be in the lexical form of a token
419
  [[lex.token]].
 
428
  check whether the controlling constant expression evaluates to nonzero.
429
 
430
  Prior to evaluation, macro invocations in the list of preprocessing
431
  tokens that will become the controlling constant expression are replaced
432
  (except for those macro names modified by the `defined` unary operator),
433
+ just as in normal text. If replacement of macros in the preprocessing
434
+ tokens following the sequence `\xname{has_embed} (` and before a
435
+ matching `)` (possibly produced by macro expansion) encounters a
436
+ preprocessing token that is one of the *identifier*s `limit`, `prefix`,
437
+ `suffix`, or `if_empty` and that *identifier* is defined as a macro
438
+ [[cpp.replace.general]], the program is ill-formed. If the preprocessing
439
+ token `defined` is generated as a result of this replacement process or
440
+ use of the `defined` unary operator does not match one of the two
441
+ specified forms prior to macro replacement, the program is ill-formed,
442
+ no diagnostic required.
443
 
444
  After all replacements due to macro expansion and evaluations of
445
+ *defined-macro-expression*s, *has-include-expression*s,
446
+ *has-embed-expression*s, and *has-attribute-expression*s have been
447
+ performed, all remaining identifiers and keywords, except for `true` and
448
+ `false`, are replaced with the *pp-number* `0`, and then each
449
+ preprocessing token is converted into a token.
450
 
451
+ [*Note 3*: An alternative token [[lex.digraph]] is not an identifier,
452
  even when its spelling consists entirely of letters and underscores.
453
  Therefore it is not subject to this replacement. — *end note*]
454
 
455
  The resulting tokens comprise the controlling constant expression which
456
  is evaluated according to the rules of  [[expr.const]] using arithmetic
457
  that has at least the ranges specified in  [[support.limits]]. For the
458
  purposes of this token conversion and evaluation all signed and unsigned
459
  integer types act as if they have the same representation as,
460
  respectively, `intmax_t` or `uintmax_t` [[cstdint.syn]].
461
 
462
+ [*Note 4*: Thus on an implementation where
463
  `std::numeric_limits<int>::max()` is `0x7FFF` and
464
  `std::numeric_limits<unsigned int>::max()` is `0xFFFF`, the integer
465
  literal `0x8000` is signed and positive within a `#if` expression even
466
  though it is unsigned in translation phase 7
467
  [[lex.phases]]. — *end note*]
468
 
469
  This includes interpreting *character-literal*s according to the rules
470
  in [[lex.ccon]].
471
 
472
+ [*Note 5*: The associated character encodings of literals are the same
473
  in `#if` and `#elif` directives and in any expression. — *end note*]
474
 
475
  Each subexpression with type `bool` is subjected to integral promotion
476
  before processing continues.
477
 
 
489
  `#if` `!defined` *identifier*, `#elif` `defined` *identifier*, and
490
  `#elif` `!defined` *identifier*, respectively.
491
 
492
  Each directive’s condition is checked in order. If it evaluates to false
493
  (zero), the group that it controls is skipped: directives are processed
494
+ only through the directive name that determines the directive in order
495
+ to keep track of the level of nested conditionals; the rest of the
496
+ directives’ preprocessing tokens are ignored, as are the other
497
+ preprocessing tokens in the group. Only the first group whose control
498
+ condition evaluates to true (nonzero) is processed; any following groups
499
+ are skipped and their controlling directives are processed as if they
500
+ were in a group that is skipped. If none of the conditions evaluates to
501
+ true, and there is a `#else` directive, the group controlled by the
502
+ `#else` is processed; lacking a `#else` directive, all the groups until
503
+ the `#endif` are skipped.[^3]
504
 
505
  [*Example 1*:
506
 
507
  This demonstrates a way to include a library `optional` facility only if
508
  it is available:
 
543
 
544
  — *end example*]
545
 
546
  ## Source file inclusion <a id="cpp.include">[[cpp.include]]</a>
547
 
548
+ A *header search* for a sequence of characters searches a sequence of
549
+ places for a header identified uniquely by that sequence of characters.
550
+ How the places are determined or the header identified is
551
+ *implementation-defined*.
552
 
553
+ A *source file search* for a sequence of characters attempts to identify
554
+ a source file that is named by the sequence of characters. The named
555
+ source file is searched for in an *implementation-defined* manner. If
556
+ the implementation does not support a source file search for that
557
+ sequence of characters, or if the search fails, the result of the source
558
+ file search is the result of a header search for the same sequence of
559
+ characters.
 
 
 
 
560
 
561
  A preprocessing directive of the form
562
 
563
  ``` bnf
564
+ '# include' header-name new-line
565
  ```
566
 
567
  causes the replacement of that directive by the entire contents of the
568
+ header or source file identified by *header-name*.
569
+
570
+ If the *header-name* is of the form
571
+
572
+ ``` bnf
573
+ '<' h-char-sequence '>'
574
+ ```
575
+
576
+ a header is identified by a header search for the sequence of characters
577
+ of the *h-char-sequence*.
578
+
579
+ If the *header-name* is of the form
580
 
581
  ``` bnf
582
+ '"' q-char-sequence '"'
583
  ```
584
 
585
+ the source file or header is identified by a source file search for the
586
+ sequence of characters of the *q-char-sequence*.
587
+
588
+ If a header search fails, or if a source file search or header search
589
+ identifies a header or source file that cannot be processed by the
590
+ implementation, the program is ill-formed.
591
+
592
+ [*Note 1*: If the header or source file cannot be processed, the
593
+ program is ill-formed even when evaluating
594
+ `__has_include`. — *end note*]
595
 
596
  A preprocessing directive of the form
597
 
598
  ``` bnf
599
  '# include' pp-tokens new-line
600
  ```
601
 
602
+ (that does not match the previous form) is permitted. The preprocessing
603
+ tokens after `include` in the directive are processed just as in normal
604
+ text (i.e., each identifier currently defined as a macro name is
605
+ replaced by its replacement list of preprocessing tokens). Then, an
606
+ attempt is made to form a *header-name* preprocessing token
607
+ [[lex.header]] from the whitespace and the characters of the spellings
608
+ of the resulting sequence of preprocessing tokens; the treatment of
609
+ whitespace is *implementation-defined*. If the attempt succeeds, the
610
+ directive with the so-formed *header-name* is processed as specified for
611
+ the previous form. Otherwise, the program is ill-formed, no diagnostic
612
+ required.
613
 
614
+ [*Note 2*: Adjacent *string-literal*s are not concatenated into a
615
+ single *string-literal* (see the translation phases in  [[lex.phases]]);
616
+ thus, an expansion that results in two *string-literal*s is an invalid
617
+ directive. — *end note*]
618
 
619
  The implementation shall provide unique mappings for sequences
620
  consisting of one or more *nondigit*s or *digit*s [[lex.name]] followed
621
  by a period (`.`) and a single *nondigit*. The first character shall not
622
  be a *digit*. The implementation may ignore distinctions of alphabetical
 
630
  header [[module.import]], it is *implementation-defined* whether the
631
  `#include` preprocessing directive is instead replaced by an `import`
632
  directive [[cpp.import]] of the form
633
 
634
  ``` bnf
635
+ import header-name ';' new-line
636
  ```
637
 
638
+ [*Note 3*:
639
 
640
  An implementation can provide a mechanism for making arbitrary source
641
  files available to the `< >` search. However, using the `< >` form for
642
  headers provided with the implementation and the `" "` form for sources
643
  outside the control of the implementation achieves wider portability.
 
667
  #include INCFILE
668
  ```
669
 
670
  — *end example*]
671
 
672
+ ## Resource inclusion <a id="cpp.embed">[[cpp.embed]]</a>
673
+
674
+ ### General <a id="cpp.embed.gen">[[cpp.embed.gen]]</a>
675
+
676
+ A *bracket resource search* for a sequence of characters searches a
677
+ sequence of places for a resource identified uniquely by that sequence
678
+ of characters. How the places are determined or the resource identified
679
+ is *implementation-defined*.
680
+
681
+ A *quote resource search* for a sequence of characters attempts to
682
+ identify a resource that is named by the sequence of characters. The
683
+ named resource is searched for in an *implementation-defined* manner. If
684
+ the implementation does not support a quote resource search for that
685
+ sequence of characters, or if the search fails, the result of the quote
686
+ resource search is the result of a bracket resource search for the same
687
+ sequence of characters.
688
+
689
+ A preprocessing directive of the form
690
+
691
+ ``` bnf
692
+ '# embed' header-name pp-tokensₒₚₜ new-line
693
+ ```
694
+
695
+ causes the replacement of that directive by preprocessing tokens derived
696
+ from data in the resource identified by *header-name*, as specified
697
+ below.
698
+
699
+ If the *header-name* is of the form
700
+
701
+ ``` bnf
702
+ '<' h-char-sequence '>'
703
+ ```
704
+
705
+ the resource is identified by a bracket resource search for the sequence
706
+ of characters of the *h-char-sequence*.
707
+
708
+ If the *header-name* is of the form
709
+
710
+ ``` bnf
711
+ '"' q-char-sequence '"'
712
+ ```
713
+
714
+ the resource is identified by a quote resource search for the sequence
715
+ of characters of the *q-char-sequence*.
716
+
717
+ If a bracket resource search fails, or if a quote or bracket resource
718
+ search identifies a resource that cannot be processed by the
719
+ implementation, the program is ill-formed.
720
+
721
+ [*Note 1*: If the resource cannot be processed, the program is
722
+ ill-formed even when processing `#embed` with `limit(0)`
723
+ [[cpp.embed.param.limit]] or evaluating `__has_embed`. — *end note*]
724
+
725
+ *Recommended practice:* A mechanism similar to, but distinct from, the
726
+ *implementation-defined* search paths used for `#include`
727
+ [[cpp.include]] is encouraged.
728
+
729
+ Either form of the `#embed` directive processes the *pp-tokens*, if
730
+ present, just as in normal text. The *pp-tokens* shall then have the
731
+ form *embed-parameter-seq*.
732
+
733
+ A resource is a source of data accessible from the translation
734
+ environment. A resource has an *implementation-resource-width*, which is
735
+ the *implementation-defined* size in bits of the resource. If the
736
+ implementation-resource-width is not an integral multiple of `CHAR_BIT`,
737
+ the program is ill-formed. Let *implementation-resource-count* be
738
+ implementation-resource-width divided by `CHAR_BIT`. Every resource also
739
+ has a *resource-count*, which is
740
+
741
+ - the value as computed from the optionally-provided `limit`
742
+ *embed-parameter* [[cpp.embed.param.limit]], if present;
743
+ - otherwise, the implementation-resource-count.
744
+
745
+ A resource is empty if the resource-count is zero.
746
+
747
+ [*Example 1*:
748
+
749
+ ``` cpp
750
+ // ill-formed if the implementation-resource-width is 6 bits
751
+ #embed "6_bits.bin"
752
+ ```
753
+
754
+ — *end example*]
755
+
756
+ The `#embed` directive is replaced by a comma-separated list of integer
757
+ literals of type `int`, unless otherwise modified by embed parameters
758
+ [[cpp.embed.param]].
759
+
760
+ The integer literals in the comma-separated list correspond to
761
+ resource-count consecutive calls to `std::fgetc` [[cstdio.syn]] from the
762
+ resource, as a binary file. If any call to `std::fgetc` returns `EOF`,
763
+ the program is ill-formed.
764
+
765
+ *Recommended practice:* The value of each integer literal should closely
766
+ represent the bit stream of the resource unmodified. This can require an
767
+ implementation to consider potential differences between translation and
768
+ execution environments, as well as any other applicable sources of
769
+ mismatch.
770
+
771
+ [*Example 2*:
772
+
773
+ ``` cpp
774
+ #include <cstring>
775
+ #include <cstddef>
776
+ #include <fstream>
777
+ #include <vector>
778
+ #include <cassert>
779
+
780
+ int main() {
781
+ // If the file is the same as the resource in the translation environment, no assert in this program should fail.
782
+ constexpr unsigned char d[] = {
783
+ #embed <data.dat>
784
+ };
785
+ const std::vector<unsigned char> vec_d = {
786
+ #embed <data.dat>
787
+ };
788
+
789
+ constexpr std::size_t expected_size = sizeof(d);
790
+
791
+ // same file in execution environment as was embedded
792
+ std::ifstream f_source("data.dat", std::ios::binary | std::ios::in);
793
+ unsigned char runtime_d[expected_size];
794
+ char* ifstream_ptr = reinterpret_cast<char*>(runtime_d);
795
+ assert(!f_source.read(ifstream_ptr, expected_size));
796
+ std::size_t ifstream_size = f_source.gcount();
797
+ assert (ifstream_size == expected_size);
798
+ int is_same = std::memcmp(&d[0], ifstream_ptr, ifstream_size);
799
+ assert(is_same == 0);
800
+ int is_same_vec = std::memcmp(vec_d.data(), ifstream_ptr, ifstream_size);
801
+ assert(is_same_vec == 0);
802
+ }
803
+ ```
804
+
805
+ — *end example*]
806
+
807
+ [*Example 3*:
808
+
809
+ ``` cpp
810
+ int i = {
811
+ #embed "i.dat"
812
+ }; // well-formed if i.dat produces a single value
813
+ int i2 =
814
+ #embed "i.dat"
815
+ ; // also well-formed if i.dat produces a single value
816
+ struct s {
817
+ double a, b, c;
818
+ struct { double e, f, g; } x;
819
+ double h, i, j;
820
+ };
821
+ s x = {
822
+ // well-formed if the directive produces nine or fewer values
823
+ #embed "s.dat"
824
+ };
825
+ ```
826
+
827
+ — *end example*]
828
+
829
+ A preprocessing directive of the form
830
+
831
+ ``` bnf
832
+ '# embed' pp-tokens new-line
833
+ ```
834
+
835
+ (that does not match the previous form) is permitted. The preprocessing
836
+ tokens after `embed` in the directive are processed just as in normal
837
+ text (i.e., each identifier currently defined as a macro name is
838
+ replaced by its replacement list of preprocessing tokens). Then, an
839
+ attempt is made to form a *header-name* preprocessing token
840
+ [[lex.header]] from the whitespace and the characters of the spellings
841
+ of the resulting sequence of preprocessing tokens immediately after
842
+ `embed`; the treatment of whitespace is *implementation-defined*. If the
843
+ attempt succeeds, the directive with the so-formed *header-name* is
844
+ processed as specified for the previous form. Otherwise, the program is
845
+ ill-formed.
846
+
847
+ [*Note 2*: Adjacent *string-literal*s are not concatenated into a
848
+ single *string-literal* (see the translation phases in  [[lex.phases]]);
849
+ thus, an expansion that results in two *string-literal*s is an invalid
850
+ directive. — *end note*]
851
+
852
+ Any further processing as in normal text described for the previous form
853
+ is not performed.
854
+
855
+ [*Note 3*: That is, processing as in normal text happens once and only
856
+ once for the entire directive. — *end note*]
857
+
858
+ [*Example 4*:
859
+
860
+ If the directive matches the second form, the whole directive is
861
+ replaced. If the directive matches the first form, everything after the
862
+ *header-name* is replaced.
863
+
864
+ ``` cpp
865
+ #define EMPTY
866
+ #define X myfile
867
+ #define Y rsc
868
+ #define Z 42
869
+ #embed <myfile.rsc> prefix(Z)
870
+ #embed EMPTY <X.Y> prefix(Z)
871
+ ```
872
+
873
+ is equivalent to:
874
+
875
+ ``` cpp
876
+ #embed <myfile.rsc> prefix(42)
877
+ #embed <myfile.rsc> prefix(42)
878
+ ```
879
+
880
+ — *end example*]
881
+
882
+ ### Embed parameters <a id="cpp.embed.param">[[cpp.embed.param]]</a>
883
+
884
+ #### limit parameter <a id="cpp.embed.param.limit">[[cpp.embed.param.limit]]</a>
885
+
886
+ An *embed-parameter* of the form `limit (` *pp-balanced-token-seq* `)`
887
+ specifies the maximum possible number of elements in the comma-delimited
888
+ list. It shall appear at most once in the *embed-parameter-seq*. The
889
+ preprocessing token `defined` shall not appear in the
890
+ *pp-balanced-token-seq*.
891
+
892
+ The *pp-balanced-token-seq* is evaluated as a *constant-expression*
893
+ using the rules as described in conditional inclusion [[cpp.cond]], but
894
+ without being processed as in normal text an additional time.
895
+
896
+ [*Example 1*:
897
+
898
+ ``` cpp
899
+ #undef DATA_LIMIT
900
+ #if __has_embed(<data.dat> limit(DATA_LIMIT))
901
+ #endif
902
+ ```
903
+
904
+ is equivalent to:
905
+
906
+ ``` cpp
907
+ #if __has_embed(<data.dat> limit(0))
908
+ #endif
909
+ ```
910
+
911
+ — *end example*]
912
+
913
+ [*Example 2*:
914
+
915
+ ``` cpp
916
+ #embed <data.dat> limit(__has_include("a.h"))
917
+
918
+ #if __has_embed(<data.dat> limit(__has_include("a.h")))
919
+ // ill-formed: __has_include[cpp.cond] cannot appear here
920
+ #endif
921
+ ```
922
+
923
+ — *end example*]
924
+
925
+ The *constant-expression* shall be an integral constant expression whose
926
+ value is greater than or equal to zero. The resource-count
927
+ [[cpp.embed.gen]] becomes implementation-resource-count, if the value of
928
+ the *constant-expression* is greater than implementation-resource-count;
929
+ otherwise, the value of the *constant-expression*.
930
+
931
+ [*Example 3*:
932
+
933
+ ``` cpp
934
+ constexpr unsigned char sound_signature[] = {
935
+ // a hypothetical resource capable of expanding to four or more elements
936
+ #embed <sdk/jump.wav> limit(2+2)
937
+ };
938
+
939
+ static_assert(sizeof(sound_signature) == 4); // OK
940
+ ```
941
+
942
+ — *end example*]
943
+
944
+ #### prefix parameter <a id="cpp.embed.param.prefix">[[cpp.embed.param.prefix]]</a>
945
+
946
+ An *embed-parameter* of the form
947
+
948
+ ``` bnf
949
+ 'prefix (' pp-balanced-token-seqₒₚₜ ')'
950
+ ```
951
+
952
+ shall appear at most once in the *embed-parameter-seq*.
953
+
954
+ If the resource is empty, this *embed-parameter* is ignored. Otherwise,
955
+ the *pp-balanced-token-seq* is placed immediately before the
956
+ comma-delimited list of integral literals.
957
+
958
+ #### suffix parameter <a id="cpp.embed.param.suffix">[[cpp.embed.param.suffix]]</a>
959
+
960
+ An *embed-parameter* of the form
961
+
962
+ ``` bnf
963
+ 'suffix (' pp-balanced-token-seqₒₚₜ ')'
964
+ ```
965
+
966
+ shall appear at most once in the *embed-parameter-seq*.
967
+
968
+ If the resource is empty, this *embed-parameter* is ignored. Otherwise,
969
+ the *pp-balanced-token-seq* is placed immediately after the
970
+ comma-delimited list of the integral constant expressions.
971
+
972
+ [*Example 1*:
973
+
974
+ ``` cpp
975
+ constexpr unsigned char whl[] = {
976
+ #embed "ches.glsl" \
977
+ prefix(0xEF, 0xBB, 0xBF, ) /* a sequence of bytes */ \
978
+ suffix(,)
979
+ 0
980
+ };
981
+ // always null-terminated, contains the sequence if not empty
982
+ constexpr bool is_empty = sizeof(whl) == 1 && whl[0] == '\0';
983
+ constexpr bool is_not_empty = sizeof(whl) >= 4
984
+ && whl[sizeof(whl) - 1] == '\0'
985
+ && whl[0] == '\xEF' && whl[1] == '\xBB' && whl[2] == '\xBF';
986
+ static_assert(is_empty || is_not_empty);
987
+ ```
988
+
989
+ — *end example*]
990
+
991
+ #### `if_empty` parameter <a id="cpp.embed.param.if.empty">[[cpp.embed.param.if.empty]]</a>
992
+
993
+ An embed-parameter of the form
994
+
995
+ ``` bnf
996
+ 'if_empty (' pp-balanced-token-seqₒₚₜ ')'
997
+ ```
998
+
999
+ shall appear at most once in the *embed-parameter-seq*.
1000
+
1001
+ If the resource is not empty, this *embed-parameter* is ignored.
1002
+ Otherwise, the `#embed` directive is replaced by the
1003
+ *pp-balanced-token-seq*.
1004
+
1005
+ [*Example 1*:
1006
+
1007
+ `limit(0)` affects when a resource is considered empty. Therefore, the
1008
+ following program:
1009
+
1010
+ ``` cpp
1011
+ #embed </owo/uwurandom> \
1012
+ if_empty(42203) limit(0)
1013
+ ```
1014
+
1015
+ expands to
1016
+
1017
+ ``` cpp
1018
+ 42203
1019
+ ```
1020
+
1021
+ — *end example*]
1022
+
1023
+ [*Example 2*:
1024
+
1025
+ This resource is considered empty due to the `limit(0)`
1026
+ *embed-parameter*, always, including in `__has_embed` clauses.
1027
+
1028
+ ``` cpp
1029
+ int infinity_zero () {
1030
+ #if __has_embed(</owo/uwurandom> limit(0) prefix(some tokens)) == __STDC_EMBED_EMPTY__
1031
+ // if </owo/uwurandom> exists, this conditional inclusion branch is taken and the function returns 0.
1032
+ return 0;
1033
+ #else
1034
+ // otherwise, the resource does not exist
1035
+ #error "The resource does not exist"
1036
+ #endif
1037
+ }
1038
+ ```
1039
+
1040
+ — *end example*]
1041
+
1042
  ## Module directive <a id="cpp.module">[[cpp.module]]</a>
1043
 
1044
  ``` bnf
1045
  pp-module:
1046
  exportₒₚₜ module pp-tokensₒₚₜ ';' new-line
1047
  ```
1048
 
1049
  A *pp-module* shall not appear in a context where `module` or (if it is
1050
+ the first preprocessing token of the *pp-module*) `export` is an
1051
+ identifier defined as an object-like macro.
1052
+
1053
+ The *pp-tokens*, if any, of a *pp-module* shall be of the form:
1054
+
1055
+ ``` bnf
1056
+ pp-module-name pp-module-partitionₒₚₜ pp-tokensₒₚₜ
1057
+ ```
1058
+
1059
+ where the *pp-tokens* (if any) shall not begin with a `(` preprocessing
1060
+ token and the grammar non-terminals are defined as:
1061
+
1062
+ ``` bnf
1063
+ pp-module-name:
1064
+ pp-module-name-qualifierₒₚₜ identifier
1065
+ ```
1066
+
1067
+ ``` bnf
1068
+ pp-module-partition:
1069
+ ':' pp-module-name-qualifierₒₚₜ identifier
1070
+ ```
1071
+
1072
+ ``` bnf
1073
+ pp-module-name-qualifier:
1074
+ identifier '.'
1075
+ pp-module-name-qualifier identifier '.'
1076
+ ```
1077
+
1078
+ No *identifier* in the *pp-module-name* or *pp-module-partition* shall
1079
+ currently be defined as an object-like macro.
1080
 
1081
  Any preprocessing tokens after the `module` preprocessing token in the
1082
  `module` directive are processed just as in normal text.
1083
 
1084
  [*Note 1*: Each identifier currently defined as a macro name is
 
1099
  exportₒₚₜ import header-name-tokens pp-tokensₒₚₜ ';' new-line
1100
  exportₒₚₜ import pp-tokens ';' new-line
1101
  ```
1102
 
1103
  A *pp-import* shall not appear in a context where `import` or (if it is
1104
+ the first preprocessing token of the *pp-import*) `export` is an
1105
+ identifier defined as an object-like macro.
1106
 
1107
  The preprocessing tokens after the `import` preprocessing token in the
1108
  `import` *control-line* are processed just as in normal text (i.e., each
1109
  identifier currently defined as a macro name is replaced by its
1110
  replacement list of preprocessing tokens).
 
1165
  unit is the first point at which a `#undef` directive naming the macro
1166
  occurs after its point of definition, or the first point of macro
1167
  import of a header unit containing a point of undefinition for the
1168
  macro definition, whichever (if any) occurs first.
1169
 
1170
+ A macro definition is *active* at a source location if it has a point of
1171
  definition in that translation unit preceding the location, and does not
1172
  have a point of undefinition in that translation unit preceding the
1173
  location.
1174
 
1175
  If a macro would be replaced or redefined, and multiple macro
 
1302
  name*. There is one name space for macro names. Any whitespace
1303
  characters preceding or following the replacement list of preprocessing
1304
  tokens are not considered part of the replacement list for either form
1305
  of macro.
1306
 
1307
+ A translation unit shall not `#define` or `#undef` macro names lexically
1308
+ identical to keywords, to the identifiers listed in
1309
+ [[lex.name.special]], or to the *attribute-token*s described in 
1310
+ [[dcl.attr]], except that the macro names `likely` and `unlikely` may be
1311
+ defined as function-like macros.
1312
+
1313
  If a `#` preprocessing token, followed by an identifier, occurs
1314
  lexically at the point at which a preprocessing directive can begin, the
1315
  identifier is not subject to macro replacement.
1316
 
1317
  A preprocessing directive of the form
 
1319
  ``` bnf
1320
  '# define' identifier replacement-list new-line
1321
  ```
1322
 
1323
  defines an *object-like macro* that causes each subsequent instance of
1324
+ the macro name[^4]
1325
 
1326
  to be replaced by the replacement list of preprocessing tokens that
1327
+ constitute the remainder of the directive.[^5]
1328
 
1329
  The replacement list is then rescanned for more macro names as specified
1330
+ in [[cpp.rescan]].
1331
 
1332
  [*Example 2*:
1333
 
1334
  The simplest use of this facility is to define a “manifest constant”, as
1335
  in
 
1365
  matching parentheses forms the list of arguments for the function-like
1366
  macro. The individual arguments within the list are separated by comma
1367
  preprocessing tokens, but comma preprocessing tokens between matching
1368
  inner parentheses do not separate arguments. If there are sequences of
1369
  preprocessing tokens within the list of arguments that would otherwise
1370
+ act as preprocessing directives,[^6]
1371
 
1372
+ the program is ill-formed.
1373
 
1374
  [*Example 3*:
1375
 
1376
  The following defines a function-like macro whose value is the maximum
1377
  of its arguments. It has the disadvantages of evaluating one or the
 
1405
 
1406
  After the arguments for the invocation of a function-like macro have
1407
  been identified, argument substitution takes place. For each parameter
1408
  in the replacement list that is neither preceded by a `#` or `##`
1409
  preprocessing token nor followed by a `##` preprocessing token, the
1410
+ preprocessing tokens naming the parameter are replaced by a
1411
+ preprocessing token sequence determined as follows:
1412
 
1413
  - If the parameter is of the form *va-opt-replacement*, the replacement
1414
  preprocessing tokens are the preprocessing token sequence for the
1415
  corresponding argument, as specified below.
1416
  - Otherwise, the replacement preprocessing tokens are the preprocessing
1417
  tokens of corresponding argument after all macros contained therein
1418
  have been expanded. The argument’s preprocessing tokens are completely
1419
  macro replaced before being substituted as if they formed the rest of
1420
+ the preprocessing translation unit with no other preprocessing tokens
1421
+ being available.
1422
 
1423
  [*Example 1*:
1424
 
1425
  ``` cpp
1426
  #define LPAREN() (
 
1536
  character string literal. Whitespace before the first preprocessing
1537
  token and after the last preprocessing token comprising the stringizing
1538
  argument is deleted. Otherwise, the original spelling of each
1539
  preprocessing token in the stringizing argument is retained in the
1540
  character string literal, except for special handling for producing the
1541
+ spelling of *header-name*s, *character-literal*s, and *string-literal*s
1542
+ (including the delimiting U+0022 (quotation mark) (`"`)) contained
1543
+ within the preprocessing token: a U+005c (reverse solidus) character
1544
+ (`\`) is inserted before each U+0022 (quotation mark) and
1545
+ U+005c (reverse solidus) character of a *header-name*,
1546
+ *character-literal*, or *string-literal*, and each new-line character is
1547
+ replaced by the two-character sequence `\n`. If the replacement that
1548
+ results is not a valid character string literal, the program is
1549
+ ill-formed. The character string literal corresponding to an empty
1550
+ stringizing argument is `""`. The order of evaluation of `#` and `##`
1551
+ operators is unspecified.
1552
 
1553
  ### The `##` operator <a id="cpp.concat">[[cpp.concat]]</a>
1554
 
1555
  A `##` preprocessing token shall not occur at the beginning or at the
1556
  end of a replacement list for either form of macro definition.
 
1558
  If, in the replacement list of a function-like macro, a parameter is
1559
  immediately preceded or followed by a `##` preprocessing token, the
1560
  parameter is replaced by the corresponding argument’s preprocessing
1561
  token sequence; however, if an argument consists of no preprocessing
1562
  tokens, the parameter is replaced by a placemarker preprocessing token
1563
+ instead.[^7]
1564
 
1565
  For both object-like and function-like macro invocations, before the
1566
  replacement list is reexamined for more macro names to replace, each
1567
  instance of a `##` preprocessing token in the replacement list (not from
1568
  an argument) is deleted and the preceding preprocessing token is
1569
  concatenated with the following preprocessing token. Placemarker
1570
  preprocessing tokens are handled specially: concatenation of two
1571
  placemarkers results in a single placemarker preprocessing token, and
1572
  concatenation of a placemarker with a non-placemarker preprocessing
1573
+ token results in the non-placemarker preprocessing token.
 
 
1574
 
1575
+ [*Note 1*: Concatenation can form a *universal-character-name*
1576
+ [[lex.charset]]. *end note*]
 
1577
 
1578
+ If the result is not a valid preprocessing token, the program is
1579
+ ill-formed. The resulting preprocessing token is available for further
1580
+ macro replacement. The order of evaluation of `##` operators is
1581
+ unspecified.
1582
 
1583
  [*Example 1*:
1584
 
1585
  The sequence
1586
 
 
1621
  #include "vers2.h" (after macro replacement, before file access)
1622
  "hello";
1623
  "hello, world"
1624
  ```
1625
 
1626
+ Space around the `#` and `##` preprocessing tokens in the macro
1627
+ definition is optional.
1628
 
1629
  — *end example*]
1630
 
1631
  [*Example 2*:
1632
 
 
1648
  in_between(x ## y)
1649
  mkstr(x ## y)
1650
  "x ## y"
1651
  ```
1652
 
1653
+ In other words, expanding `hash_hash` produces a new preprocessing
1654
+ token, consisting of two adjacent sharp signs, but this new
1655
+ preprocessing token is not the `##` operator.
1656
 
1657
  — *end example*]
1658
 
1659
  [*Example 3*:
1660
 
 
1756
  ## Line control <a id="cpp.line">[[cpp.line]]</a>
1757
 
1758
  The *string-literal* of a `#line` directive, if present, shall be a
1759
  character string literal.
1760
 
1761
+ The *line number* of the current source line is the line number of the
1762
+ current physical source line, i.e., it is one greater than the number of
1763
+ new-line characters read or introduced in translation phase 1
1764
+ [[lex.phases]] while processing the source file to the current
1765
+ preprocessing token.
1766
 
1767
  A preprocessing directive of the form
1768
 
1769
  ``` bnf
1770
  '# line' digit-sequence new-line
 
1772
 
1773
  causes the implementation to behave as if the following sequence of
1774
  source lines begins with a source line that has a line number as
1775
  specified by the digit sequence (interpreted as a decimal integer). If
1776
  the digit sequence specifies zero or a number greater than 2147483647,
1777
+ the program is ill-formed.
1778
 
1779
  A preprocessing directive of the form
1780
 
1781
  ``` bnf
1782
  '# line' digit-sequence '"' s-char-sequenceₒₚₜ '"' new-line
 
1794
  (that does not match one of the two previous forms) is permitted. The
1795
  preprocessing tokens after `line` on the directive are processed just as
1796
  in normal text (each identifier currently defined as a macro name is
1797
  replaced by its replacement list of preprocessing tokens). If the
1798
  directive resulting after all replacements does not match one of the two
1799
+ previous forms, the program is ill-formed; otherwise, the result is
1800
  processed as appropriate.
1801
 
1802
  ## Diagnostic directives <a id="cpp.error">[[cpp.error]]</a>
1803
 
1804
+ A preprocessing directive of the form
1805
 
1806
  ``` bnf
1807
  '# error' pp-tokensₒₚₜ new-line
1808
+ ```
1809
+
1810
+ renders the program ill-formed. A preprocessing directive of the form
1811
+
1812
+ ``` bnf
1813
  '# warning' pp-tokensₒₚₜ new-line
1814
  ```
1815
 
1816
+ requires the implementation to produce at least one diagnostic message
1817
+ for the preprocessing translation unit [[intro.compliance.general]].
1818
+
1819
+ *Recommended practice:* Any diagnostic message caused by either of these
1820
+ directives should include the specified sequence of preprocessing
1821
+ tokens.
1822
 
1823
  ## Pragma directive <a id="cpp.pragma">[[cpp.pragma]]</a>
1824
 
1825
  A preprocessing directive of the form
1826
 
 
1850
 
1851
  - **`__cplusplus`**
1852
 
1853
  The integer literal `202302L`.
1854
 
1855
+ [*Note 1*: Future revisions of this document will replace the value of
1856
+ this macro with a greater value. — *end note*]
1857
 
1858
+ - **The macro names listed in [[cpp.predefined.ft]].**
1859
 
1860
  The macros defined in [[cpp.predefined.ft]] shall be defined to the
1861
  corresponding integer literal.
1862
 
1863
+ [*Note 2*: Future revisions of this document might replace the values
1864
+ of these macros with greater values. — *end note*]
1865
 
1866
  - **`__DATE__`**
1867
 
1868
  The date of translation of the source file: a character string literal
1869
  of the form `"Mmm dd yyyy"`, where the names of the months are the same
 
1872
  translation is not available, an *implementation-defined* valid date
1873
  shall be supplied.
1874
 
1875
  - **`__FILE__`**
1876
 
1877
+ A character string literal representing the presumed name of the current
1878
+ source file.
1879
+
1880
+ [*Note 3*: The presumed source file name can be changed by the `#line`
1881
+ directive [[cpp.line]]. — *end note*]
1882
 
1883
  - **`__LINE__`**
1884
 
1885
+ An integer literal representing the presumed line number of the current
1886
+ source line within the current source file.
1887
+
1888
+ [*Note 4*: The presumed line number can be changed by the `#line`
1889
+ directive [[cpp.line]]. — *end note*]
1890
+
1891
+ - **`__STDC_EMBED_NOT_FOUND__, __STDC_EMBED_FOUND__, and __STDC_EMBED_EMPTY__`**
1892
+
1893
+ The integer literals `0`, `1`, and `2`, respectively.
1894
+
1895
+ [*Note 5*: These represent values replaced from
1896
+ \*has-embed-expression\*s [[cpp.cond]]. — *end note*]
1897
 
1898
  - **`__STDC_HOSTED__`**
1899
 
1900
  The integer literal `1` if the implementation is a hosted implementation
1901
  or the integer literal `0` if it is a freestanding implementation
 
1905
 
1906
  An integer literal of type `std::size_t` whose value is the alignment
1907
  guaranteed by a call to `operator new(std::size_t)` or
1908
  `operator new[](std::size_t)`.
1909
 
1910
+ [*Note 6*: Larger alignments will be passed to
1911
  `operator new(std::size_t, std::align_val_t)`, etc.
1912
  [[expr.new]]. — *end note*]
1913
 
1914
  - **`__STDCPP_FLOAT16_T__`**
1915
 
1916
  Defined as the integer literal `1` if and only if the implementation
1917
+ supports the ISO/IEC 60559 floating-point interchange format binary16 as
1918
+ an extended floating-point type [[basic.extended.fp]].
1919
 
1920
  - **`__STDCPP_FLOAT32_T__`**
1921
 
1922
  Defined as the integer literal `1` if and only if the implementation
1923
+ supports the ISO/IEC 60559 floating-point interchange format binary32 as
1924
+ an extended floating-point type.
1925
 
1926
  - **`__STDCPP_FLOAT64_T__`**
1927
 
1928
  Defined as the integer literal `1` if and only if the implementation
1929
+ supports the ISO/IEC 60559 floating-point interchange format binary64 as
1930
+ an extended floating-point type.
1931
 
1932
  - **`__STDCPP_FLOAT128_T__`**
1933
 
1934
  Defined as the integer literal `1` if and only if the implementation
1935
+ supports the ISO/IEC 60559 floating-point interchange format binary128
1936
+ as an extended floating-point type.
1937
 
1938
  - **`__STDCPP_BFLOAT16_T__`**
1939
 
1940
  Defined as the integer literal `1` if and only if the implementation
1941
  supports an extended floating-point type with the properties of the
 
1963
  | `__cpp_binary_literals` | `201304L` |
1964
  | `__cpp_capture_star_this` | `201603L` |
1965
  | `__cpp_char8_t` | `202207L` |
1966
  | `__cpp_concepts` | `202002L` |
1967
  | `__cpp_conditional_explicit` | `201806L` |
1968
+ | `__cpp_consteval` | `202211L` |
1969
+ | `__cpp_constexpr` | `202406L` |
1970
  | `__cpp_constexpr_dynamic_alloc` | `201907L` |
1971
+ | `__cpp_constexpr_exceptions` | `202411L` |
1972
  | `__cpp_constexpr_in_decltype` | `201711L` |
1973
+ | `__cpp_constexpr_virtual_inheritance` | `202506L` |
1974
  | `__cpp_constinit` | `201907L` |
1975
+ | `__cpp_contracts` | `202502L` |
1976
  | `__cpp_decltype` | `200707L` |
1977
  | `__cpp_decltype_auto` | `201304L` |
1978
+ | `__cpp_deduction_guides` | `202207L` |
1979
  | `__cpp_delegating_constructors` | `200604L` |
1980
+ | `__cpp_deleted_function` | `202403L` |
1981
  | `__cpp_designated_initializers` | `201707L` |
1982
  | `__cpp_enumerator_attributes` | `201411L` |
1983
+ | `__cpp_expansion_statements` | `202506L` |
1984
  | `__cpp_explicit_this_parameter` | `202110L` |
1985
  | `__cpp_fold_expressions` | `201603L` |
1986
  | `__cpp_generic_lambdas` | `201707L` |
1987
  | `__cpp_guaranteed_copy_elision` | `201606L` |
1988
  | `__cpp_hex_float` | `201603L` |
1989
  | `__cpp_if_consteval` | `202106L` |
1990
  | `__cpp_if_constexpr` | `201606L` |
1991
  | `__cpp_impl_coroutine` | `201902L` |
1992
  | `__cpp_impl_destroying_delete` | `201806L` |
1993
+ | `__cpp_impl_reflection` | `202506L` |
1994
  | `__cpp_impl_three_way_comparison` | `201907L` |
1995
  | `__cpp_implicit_move` | `202207L` |
1996
  | `__cpp_inheriting_constructors` | `201511L` |
1997
  | `__cpp_init_captures` | `201803L` |
1998
  | `__cpp_initializer_lists` | `200806L` |
 
2004
  | `__cpp_namespace_attributes` | `201411L` |
2005
  | `__cpp_noexcept_function_type` | `201510L` |
2006
  | `__cpp_nontype_template_args` | `201911L` |
2007
  | `__cpp_nontype_template_parameter_auto` | `201606L` |
2008
  | `__cpp_nsdmi` | `200809L` |
2009
+ | `__cpp_pack_indexing` | `202311L` |
2010
+ | `__cpp_placeholder_variables` | `202306L` |
2011
+ | `__cpp_pp_embed` | `202502L` |
2012
  | `__cpp_range_based_for` | `202211L` |
2013
  | `__cpp_raw_strings` | `200710L` |
2014
  | `__cpp_ref_qualifiers` | `200710L` |
2015
  | `__cpp_return_type_deduction` | `201304L` |
2016
  | `__cpp_rvalue_references` | `200610L` |
2017
  | `__cpp_size_t_suffix` | `202011L` |
2018
  | `__cpp_sized_deallocation` | `201309L` |
2019
+ | `__cpp_static_assert` | `202306L` |
2020
  | `__cpp_static_call_operator` | `202207L` |
2021
+ | `__cpp_structured_bindings` | `202411L` |
2022
+ | `__cpp_template_parameters` | `202502L` |
2023
  | `__cpp_template_template_args` | `201611L` |
2024
  | `__cpp_threadsafe_static_init` | `200806L` |
2025
+ | `__cpp_trivial_relocatability` | `202502L` |
2026
+ | `__cpp_trivial_union` | `202502L` |
2027
  | `__cpp_unicode_characters` | `200704L` |
2028
  | `__cpp_unicode_literals` | `200710L` |
2029
  | `__cpp_user_defined_literals` | `200809L` |
2030
  | `__cpp_using_enum` | `201907L` |
2031
  | `__cpp_variable_templates` | `201304L` |
2032
+ | `__cpp_variadic_friend` | `202403L` |
2033
  | `__cpp_variadic_templates` | `200704L` |
2034
  | `__cpp_variadic_using` | `201611L` |
2035
 
2036
 
2037
  The following macro names are conditionally defined by the
 
2068
  The values of the predefined macros (except for `__FILE__` and
2069
  `__LINE__`) remain constant throughout the translation unit.
2070
 
2071
  If any of the pre-defined macro names in this subclause, or the
2072
  identifier `defined`, is the subject of a `#define` or a `#undef`
2073
+ preprocessing directive, the program is ill-formed. Any other predefined
2074
  macro names shall begin with a leading underscore followed by an
2075
  uppercase letter or a second underscore.
2076
 
2077
  ## Pragma operator <a id="cpp.pragma.op">[[cpp.pragma.op]]</a>
2078
 
 
2119
  [basic.extended.fp]: basic.md#basic.extended.fp
2120
  [cpp]: #cpp
2121
  [cpp.concat]: #cpp.concat
2122
  [cpp.cond]: #cpp.cond
2123
  [cpp.cond.ha]: #cpp.cond.ha
2124
+ [cpp.embed]: #cpp.embed
2125
+ [cpp.embed.gen]: #cpp.embed.gen
2126
+ [cpp.embed.param]: #cpp.embed.param
2127
+ [cpp.embed.param.if.empty]: #cpp.embed.param.if.empty
2128
+ [cpp.embed.param.limit]: #cpp.embed.param.limit
2129
+ [cpp.embed.param.prefix]: #cpp.embed.param.prefix
2130
+ [cpp.embed.param.suffix]: #cpp.embed.param.suffix
2131
  [cpp.error]: #cpp.error
2132
  [cpp.import]: #cpp.import
2133
  [cpp.include]: #cpp.include
2134
  [cpp.line]: #cpp.line
2135
  [cpp.module]: #cpp.module
 
2144
  [cpp.rescan]: #cpp.rescan
2145
  [cpp.scope]: #cpp.scope
2146
  [cpp.stringize]: #cpp.stringize
2147
  [cpp.subst]: #cpp.subst
2148
  [cstdint.syn]: support.md#cstdint.syn
2149
+ [cstdio.syn]: input.md#cstdio.syn
2150
+ [dcl.attr]: dcl.md#dcl.attr
2151
  [expr.const]: expr.md#expr.const
2152
  [expr.new]: expr.md#expr.new
2153
  [intro.compliance]: intro.md#intro.compliance
2154
+ [intro.compliance.general]: intro.md#intro.compliance.general
2155
  [intro.multithread]: basic.md#intro.multithread
2156
  [lex.ccon]: lex.md#lex.ccon
2157
+ [lex.charset]: lex.md#lex.charset
2158
  [lex.digraph]: lex.md#lex.digraph
2159
+ [lex.header]: lex.md#lex.header
2160
  [lex.key]: lex.md#lex.key
2161
  [lex.name]: lex.md#lex.name
2162
+ [lex.name.special]: #lex.name.special
2163
  [lex.phases]: lex.md#lex.phases
2164
  [lex.token]: lex.md#lex.token
2165
  [module.import]: module.md#module.import
2166
  [support.limits]: support.md#support.limits
2167
 
 
2178
  [^3]: As indicated by the syntax, a preprocessing token cannot follow a
2179
  `#else` or `#endif` directive before the terminating new-line
2180
  character. However, comments can appear anywhere in a source file,
2181
  including within a preprocessing directive.
2182
 
2183
+ [^4]: Since, by macro-replacement time, all *character-literal*s and
 
 
 
 
 
2184
  *string-literal*s are preprocessing tokens, not sequences possibly
2185
  containing identifier-like subsequences (see [[lex.phases]],
2186
  translation phases), they are never scanned for macro names or
2187
  parameters.
2188
 
2189
+ [^5]: An alternative token [[lex.digraph]] is not an identifier, even
2190
  when its spelling consists entirely of letters and underscores.
2191
  Therefore it is not possible to define a macro whose name is the
2192
  same as that of an alternative token.
2193
 
2194
+ [^6]: A *conditionally-supported-directive* is a preprocessing directive
2195
  regardless of whether the implementation supports it.
2196
 
2197
+ [^7]: Placemarker preprocessing tokens do not appear in the syntax
2198
  because they are temporary entities that exist only within
2199
  translation phase 4.