Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!usc!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.std.c Subject: dollar signs in identifiers (was: warning: '/*' within comment) Message-ID: <16812@haddock.ima.isc.com> Date: 7 Jun 90 01:51:39 GMT References: <1990Jun1.200433.6919@druid.uucp> <16786@haddock.ima.isc.com> <371@necssd.NEC.COM> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 32 In article <371@necssd.NEC.COM> harrison@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 #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@ima.ima.isc.com or harvard!ima!karl), The Walking Lint