<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 626</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="626"></A><H4>626.
  
Preprocessor string literals
</H4>
<B>Section: </B>15.7.3&#160; [<A href="https://wg21.link/cpp.stringize">cpp.stringize</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD2
 &#160;&#160;&#160;

 <B>Submitter: </B>Gennaro Prota
 &#160;&#160;&#160;

 <B>Date: </B>12 September 2006<BR>


<P>[Voted into WP at October, 2009 meeting.]</P>

<P>Clause 15 [<A href="https://wg21.link/cpp">cpp</A>] refers in several places to
&#8220;character string literals&#8221; without specifying
whether they are narrow or wide strings.  For instance, what kind
of string does the <TT>#</TT> operator (15.7.3 [<A href="https://wg21.link/cpp.stringize">cpp.stringize</A>]) produce?</P>

<P>15.8 [<A href="https://wg21.link/cpp.line#1">cpp.line</A>] paragraph 1 says,</P>

<BLOCKQUOTE>

The string literal of a <TT>#line</TT> directive, if present, shall be a
character string literal.

</BLOCKQUOTE>

<P>Is &#8220;character string literal&#8221; intended to mean a
narrow string literal?  (Also, there is no <I>string-literal</I>
mentioned in the grammatical descriptions of <TT>#line</TT>;
paragraph 4 reads,</P>

<P><UL>
<TT># line</TT> <I>digit-sequence</I> <TT>"</TT> <I>s-char-sequence<SUB>opt</SUB></I> <TT>"</TT> <I>new-line</I>
</UL></P>

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

<P>15.12 [<A href="https://wg21.link/cpp.predefined">cpp.predefined</A>] should also specify what kind of
character string literals are produced by the various string-valued
predefined macros.</P>

<P><B>Notes from the July, 2007 meeting:</B></P>

<P>The CWG affirmed that all the string literals mentioned in
Clause 15 [<A href="https://wg21.link/cpp">cpp</A>] are intended to be narrow strings.</P>

<P><B>Proposed resolution (September, 2008)</B></P>

<OL>
<LI><P>Change the footnote in Clause 15 [<A href="https://wg21.link/cpp#1">cpp</A>] paragraph 1 as
follows:
</P></LI>

<BLOCKQUOTE>

Thus, preprocessing directives are commonly called
&#8220;lines.&#8221; These &#8220;lines&#8221; have no other
syntactic significance, as all white space is equivalent except
in certain situations during preprocessing (see the <TT>#</TT>
<DEL>character</DEL> string literal creation operator in 15.7.3 [<A href="https://wg21.link/cpp.stringize">cpp.stringize</A>], for example).

</BLOCKQUOTE>

<LI><P>Change 15.7.3 [<A href="https://wg21.link/cpp.stringize#2">cpp.stringize</A>] paragraph 2 as follows:
</P></LI>

<BLOCKQUOTE>

If, in the replacement list, a parameter is immediately preceded
by a <TT>#</TT> preprocessing token, both are replaced by a
single <DEL>character</DEL> <INS>ordinary</INS> string literal
<INS>(5.13.5 [<A href="https://wg21.link/lex.string">lex.string</A>])</INS> 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
<DEL>character</DEL> <INS>ordinary</INS> string literal, except for special
handling for producing the spelling of string literals and
character literals: a <TT>\</TT> character is inserted before
each <TT>"</TT> and <TT>\</TT> character of a character literal
or string literal (including the delimiting <TT>"</TT>
characters). If the replacement that results is not a valid
<DEL>character</DEL> <INS>ordinary</INS> string literal, the behavior is
undefined. The <DEL>character</DEL> <INS>ordinary</INS> string literal
corresponding to an empty argument is <TT>""</TT>. The order of
evaluation of <TT>#</TT> and <TT>##</TT> operators is
unspecified.

</BLOCKQUOTE>

<LI><P>Change 15.7.6 [<A href="https://wg21.link/cpp.scope#6">cpp.scope</A>] paragraph 6 as follows:
</P></LI>

<BLOCKQUOTE>

To illustrate the rules for creating <DEL>character</DEL>
<INS>ordinary</INS> string literals and concatenating tokens, the
sequence... or, after concatenation of the <DEL>character</DEL>
<INS>ordinary</INS> string literals...

</BLOCKQUOTE>

<LI><P>Change 15.8 [<A href="https://wg21.link/cpp.line#1">cpp.line</A>] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

The string literal of a <TT>#line</TT> directive, if present,
shall be <DEL>a character</DEL> <INS>an ordinary</INS> string literal.

</BLOCKQUOTE>

<LI><P>Change 15.8 [<A href="https://wg21.link/cpp.line#4">cpp.line</A>] paragraph 4 as follows:
</P></LI>

<BLOCKQUOTE>

...and changes the presumed name of the source file to be the
contents of the <DEL>character</DEL> <INS>ordinary</INS> string literal.

</BLOCKQUOTE>

<LI><P>Change 15.12 [<A href="https://wg21.link/cpp.predefined#1">cpp.predefined</A>] paragraph 1 as follows:
</P></LI>

<BLOCKQUOTE>

<P>__DATE__</P>

<UL>The date of translation of the source file
(<DEL>a character</DEL> <INS>an ordinary</INS> string literal of the form...</UL>

<P>__FILE__</P>

<UL>The presumed name of the source file (<DEL>a character</DEL>
<INS>an ordinary</INS> string literal).</UL>

<P>...</P>

<P>__TIME__</P>

<UL>The time of translation of the source file (<DEL>a character</DEL>
<INS>an ordinary</INS> string literal of the form...</UL>

</BLOCKQUOTE>
</OL>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>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.</P>

<P><B>Additional notes (May, 2009):</B></P>

<P>At its most recent meeting, the C Committee decided to keep
the existing term, &#8220;character string literal.&#8221;</P>

<P>One possibility for maintaining compatible phraseology with
the C Standard would be to replace the occurrences of &#8220;ordinary
string literal&#8221; in 5.13.5 [<A href="https://wg21.link/lex.string">lex.string</A>] with
&#8220;character string literal,&#8221; instead of the extensive
set of changes above.</P>

<P>Another possibility would be to leave the references in
Clause 15 [<A href="https://wg21.link/cpp">cpp</A>] unchanged and just insert a prefatory comment
near the beginning that every occurrence of &#8220;character string
literal&#8221; refers to a <I>string-literal</I> with no prefix.  (The
use of &#8220;ordinary string literal&#8221; in the preceding edits is
problematic in that the phrase includes raw string literals as well as
unprefixed literals.)</P>

<P><B>Proposed resolution (July, 2009):</B></P>

<OL>
<LI><P>Change 15.7.3 [<A href="https://wg21.link/cpp.stringize#2">cpp.stringize</A>] paragraph 2 as
follows:</P></LI>

<BLOCKQUOTE>

<INS>A <I>character string literal</I> is a <I>string-literal</I> with
no prefix.</INS> If, in the replacement list, a parameter is
immediately preceded by a <TT>#</TT> preprocessing token...

</BLOCKQUOTE>

<LI><P>Change the fifteenth bullet of Annex Clause Annex B [<A href="https://wg21.link/implimits#2">implimits</A>] paragraph 2
as follows:</P></LI>

<UL><LI>Characters in a <DEL>character</DEL> string literal <DEL>or
wide string literal</DEL> (after concatenation) [65 536].</LI></UL>

</OL>

<BR><BR>
</BODY>
</HTML>
