Title
Preprocessor string literals
Status
cd2
Section
15.6.3 [cpp.stringize]
Submitter
Gennaro Prota

Created on 2006-09-12.00:00:00 last changed 171 months ago

Messages

Date: 2009-10-15.00:00:00

[Voted into WP at October, 2009 meeting.]

Date: 2009-07-15.00:00:00

Proposed resolution (July, 2009):

  1. Change 15.6.3 [cpp.stringize] paragraph 2 as follows:

  2. A character string literal is a string-literal with no prefix. If, in the replacement list, a parameter is immediately preceded by a # preprocessing token...
  3. Change the fifteenth bullet of Annex Clause Annex B [implimits] paragraph 2 as follows:

    • Characters in a character string literal or wide string literal (after concatenation) [65 536].
Date: 2009-05-15.00:00:00

Additional notes (May, 2009):

At its most recent meeting, the C Committee decided to keep the existing term, “character string literal.”

One possibility for maintaining compatible phraseology with the C Standard would be to replace the occurrences of “ordinary string literal” in 5.13.5 [lex.string] with “character string literal,” instead of the extensive set of changes above.

Another possibility would be to leave the references in Clause 15 [cpp] unchanged and just insert a prefatory comment near the beginning that every occurrence of “character string literal” refers to a string-literal with no prefix. (The use of “ordinary string literal” in the preceding edits is problematic in that the phrase includes raw string literals as well as unprefixed literals.)

Date: 2008-09-15.00:00:00

Notes from the September, 2008 meeting:

The proposed resolution will be discussed with the C Committee before proceeding, as it is expected that the next revision of the C Standard will also adopt new forms of string literals.

Date: 2008-09-15.00:00:00

Proposed resolution (September, 2008)

  1. Change the footnote in Clause 15 [cpp] paragraph 1 as follows:

  2. Thus, preprocessing directives are commonly called “lines.” These “lines” have no other syntactic significance, as all white space is equivalent except in certain situations during preprocessing (see the # character string literal creation operator in 15.6.3 [cpp.stringize], for example).
  3. Change 15.6.3 [cpp.stringize] paragraph 2 as follows:

  4. If, in the replacement list, a parameter is immediately preceded by a # preprocessing token, both are replaced by a single character ordinary string literal (5.13.5 [lex.string]) preprocessing token that contains the spelling of the preprocessing token sequence for the corresponding argument... Otherwise, the original spelling of each preprocessing token in the argument is retained in the character ordinary string literal, except for special handling for producing the spelling of string literals and character literals: a \ character is inserted before each " and \ character of a character literal or string literal (including the delimiting " characters). If the replacement that results is not a valid character ordinary string literal, the behavior is undefined. The character ordinary string literal corresponding to an empty argument is "". The order of evaluation of # and ## operators is unspecified.
  5. Change 15.6.6 [cpp.scope] paragraph 6 as follows:

  6. To illustrate the rules for creating character ordinary string literals and concatenating tokens, the sequence... or, after concatenation of the character ordinary string literals...
  7. Change 15.7 [cpp.line] paragraph 1 as follows:

  8. The string literal of a #line directive, if present, shall be a character an ordinary string literal.
  9. Change 15.7 [cpp.line] paragraph 4 as follows:

  10. ...and changes the presumed name of the source file to be the contents of the character ordinary string literal.
  11. Change 15.11 [cpp.predefined] paragraph 1 as follows:

  12. __DATE__

      The date of translation of the source file (a character an ordinary string literal of the form...

    __FILE__

      The presumed name of the source file (a character an ordinary string literal).

    ...

    __TIME__

      The time of translation of the source file (a character an ordinary string literal of the form...
Date: 2007-07-15.00:00:00

Notes from the July, 2007 meeting:

The CWG affirmed that all the string literals mentioned in Clause 15 [cpp] are intended to be narrow strings.

Date: 2022-02-18.07:47:23

Clause 15 [cpp] refers in several places to “character string literals” without specifying whether they are narrow or wide strings. For instance, what kind of string does the # operator (15.6.3 [cpp.stringize]) produce?

15.7 [cpp.line] paragraph 1 says,

The string literal of a #line directive, if present, shall be a character string literal.

Is “character string literal” intended to mean a narrow string literal? (Also, there is no string-literal mentioned in the grammatical descriptions of #line; paragraph 4 reads,

    # line digit-sequence " s-char-sequenceopt " new-line

which is apparently intended to suggest a string literal but does not use the term.)

15.11 [cpp.predefined] should also specify what kind of character string literals are produced by the various string-valued predefined macros.

History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: dr -> cd2
2009-11-08 00:00:00adminsetmessages: + msg2481
2009-11-08 00:00:00adminsetstatus: ready -> dr
2009-08-03 00:00:00adminsetmessages: + msg2181
2009-08-03 00:00:00adminsetstatus: review -> ready
2009-06-19 00:00:00adminsetmessages: + msg2044
2008-10-05 00:00:00adminsetmessages: + msg1770
2008-05-18 00:00:00adminsetmessages: + msg1641
2008-05-18 00:00:00adminsetstatus: drafting -> review
2007-08-05 00:00:00adminsetmessages: + msg1522
2007-08-05 00:00:00adminsetstatus: open -> drafting
2006-09-12 00:00:00admincreate