This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Universal Character Names, v2
Geoff Keating <geoffk@geoffk.org> writes:
> Is this intended to be an extension to C99? I think it is; C99
> doesn't support things that start with digits and then contain
> non-digits (as specified by C99) in them.
It sure does. Consider 6.4.8:
pp-number:
digit
. digit
pp-number digit
pp-number identifier-nondigit
pp-number e sign
pp-number E sign
pp-number p sign
pp-number P sign
pp-number .
and then 6.4.2.1:
identifier-nondigit:
nondigit
universal-character-name
other implementation-defined characters
So UCNs in pp-numbers are supported in the language. Same for C++.
[disclaimer: this is again from my C99 draft. If the final version
is different, please let me know. For C++, I'm certain that UCNs
are allowed in pp-numbers ]
> I believe that support for more kinds of digit was explicitly
> considered and rejected by the C standards committee, on the grounds
> that (a) it provides no useful functionality, and (b) it makes it
> harder to process C source files without having a full C tokenizer,
> because now even recognizing the start of a number requires full UCN
> processing.
No. You cannot start a pp-number with a UCN. I'm not sure what the
rationale is for allowing nondigits in a number, but I found two
reasonable uses:
- you may want to paste a pp-number to an identifier to get another
identifier.
- you can use the preprocessor to support different languages. For
example, OMG IDL uses a "D" (or "d") suffix to denote fixed-point
numbers, and specifies that the ISO 14882 preprocessor is used.
Thanks for your comments,
Martin