> > > Hi all,
> > >
[quoted text clipped - 21 lines]
> that is not part of an reserved word/ identifier/ operator/ etc is
> considered a separate token.
Technically the dollar isn't even recognized as a character...
>And, should'n the compiler give an error if it
> finds invalid characters?
It does, if you select "Disable Language Extensions". Seems like allowing $
is yet another MS extension!
Bo Persson
SaGS - 28 Dec 2003 04:10 GMT
> ...
> It does, if you select "Disable Language Extensions". Seems like allowing $
> is yet another MS extension!
> ...
Yes, you're right here. What irritates me is that I haven't found this
documented; maybe it's an "unintended MS extension" (= bug)!
Further investigation shows a little mess about invalid characters. From the
C/C++ perspective, "@" and "`" (backquote) are in the same situation as "$":
these are the only characters in the source charset (7-bit ASCII) that are
not used. (Exception: "@" is used by the MS-specific preprocessor operator
"@#").
But:
(a) If they appear as-is: "@" and "`" always give "error C2018: unknown
character 'hexnumber'", while "$" gives C2018 only in ANSI mode, and is
accepted as (part of) an identifier with MS Extensions.
(b) "$" and "@" can be inserted in an identifier, even in ANSI-compatible
mode, using Unicode Character Names:
int \u0024;
creates a variable named "$". "`" cannot be specified with an UCN (UCN are
only accepted for extended characters, "$" and "@"; this is documented).
(c) As a side-note, error messages regarding identifiers "\u0024" and
"\u0040" refer to "operator `$'" and "operator `@'"!!!