This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: UCNs in identifiers
On Fri, 11 Mar 2005, Geoff Keating wrote:
> > Otherwise, the original spelling of each preprocessing token in the argument
> > is retained in the character string literal, except for special handling for
> > producing the spelling of string literals and character constants: a \
> > character is inserted before each " and \ character of a character constant
> > or string literal (including the delimiting " characters), except that it is
> > implementation-defined whether a \ character is inserted before the \
> > character beginning a universal character name.
>
> So #\u00AA gets turned into "\u00AA".
You can stringize twice. So it's actually C++ which has the strict
requirements for spelling preservation in this case, e.g.
#define h(x) #x
#define str(x) h(x)
const char *s = str(str(\u00AA));
(since in C99 you might just keep a UCN as a UCN when repeatedly
stringizing a string, but in C++ the backslashes must be doubled: the
special wording about implementation-definedness is not in C++).
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)