dollar signs in identifiers (was: warning: '/*' within comment)
Karl Heuer
karl at haddock.ima.isc.com
Thu Jun 7 11:51:39 AEST 1990
In article <371 at necssd.NEC.COM> harrison at necssd.NEC.COM (Mark Harrison) writes:
> #if VMS
> extern char * x$something; /* however it's done */
> #endif
As noted in the previous article, the quote is shielded by the comment. That
`$' is a bit trickier, though. It lexes into a single pp-token, which is
excluded along with its neighbors on a non-VMS system (assuming the symbol VMS
has the obvious meaning); I presume that if there's ever an ANSI compiler on
VMS, it will issue a trivial diagnostic, and, since the presence of the
invalid token throws us into the realm of Undefined Behavior, the compiler
will conveniently choose to define this situation to mean `glue these together
into a single token'.
Or more likely, such a compiler will support something like `#pragma enable
extended_identifiers', since that would allow the expected behavior for
macros, too. (The Standard requires that the strictly conforming program
#include <stdio.h>
#define foo$bar /* define foo to be dollar-bar */
#ifdef foo
int main(void) { printf("yes\n"); return 0; }
#else
int main(void) { printf("no\n"); return 0; }
#endif
must print "yes"; normal VMS behavior would be to treat `foo$bar' as a single
token and print "no".)
Personally, I think the treatment of unexpected characters should have been
implementation-defined. But hey, DEC and Apollo both had representatives on
the Committee, and if they're satisfied, who am I to complain?
Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint
More information about the Comp.std.c
mailing list