56 lines
3.0 KiB
Markdown
56 lines
3.0 KiB
Markdown
[cpp.stringize]
|
||
|
||
# 15 Preprocessing directives [[cpp]](./#cpp)
|
||
|
||
## 15.7 Macro replacement [[cpp.replace]](cpp.replace#cpp.stringize)
|
||
|
||
### 15.7.3 The # operator [cpp.stringize]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L1795)
|
||
|
||
Each# preprocessing token in the replacement list for a function-like
|
||
macro shall be followed by a parameter as the next preprocessing
|
||
token in the replacement list[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L1802)
|
||
|
||
A [*character string literal*](#def:character_string_literal "15.7.3 The # operator [cpp.stringize]") is a [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]") with no prefix[.](#2.sentence-1)
|
||
|
||
If, in the replacement list, a parameter is immediately
|
||
preceded by a# preprocessing token,
|
||
both are replaced by a single character string literal preprocessing token that
|
||
contains the spelling of the preprocessing token sequence for the
|
||
corresponding argument (excluding placemarker tokens)[.](#2.sentence-2)
|
||
|
||
Let the [*stringizing argument*](#def:stringizing_argument "15.7.3 The # operator [cpp.stringize]") be the preprocessing token sequence
|
||
for the corresponding argument with placemarker tokens removed[.](#2.sentence-3)
|
||
|
||
Each occurrence of whitespace between the stringizing argument's preprocessing
|
||
tokens becomes a single space character in the character string literal[.](#2.sentence-4)
|
||
|
||
Whitespace before the first preprocessing token and after the last
|
||
preprocessing token comprising the stringizing argument is deleted[.](#2.sentence-5)
|
||
|
||
Otherwise, the original spelling of each preprocessing token in the
|
||
stringizing argument is retained in the character string literal,
|
||
except for special handling for producing the spelling of[*header-name*](lex.header#nt:header-name "5.6 Header names [lex.header]")*s*,[*character-literal*](lex.ccon#nt:character-literal "5.13.3 Character literals [lex.ccon]")*s*,
|
||
and [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]")*s* (including the delimiting U+0022 quotation mark ("))
|
||
contained within the preprocessing token:
|
||
a U+005c reverse solidus character (\)
|
||
is inserted before each U+0022 quotation mark andU+005c reverse solidus character of a[*header-name*](lex.header#nt:header-name "5.6 Header names [lex.header]"),[*character-literal*](lex.ccon#nt:character-literal "5.13.3 Character literals [lex.ccon]"),
|
||
or [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]"),
|
||
and each new-line character is
|
||
replaced by the two-character sequence \n[.](#2.sentence-6)
|
||
|
||
If the replacement that results is not a valid character string literal,
|
||
the program is ill-formed[.](#2.sentence-7)
|
||
|
||
The character string literal corresponding to
|
||
an empty stringizing argument is ""[.](#2.sentence-8)
|
||
|
||
The order of evaluation of# and## operators is unspecified[.](#2.sentence-9)
|