3B2 cpp #ifdef + #include

Karl Heuer karl at haddock.ISC.COM
Thu Mar 31 11:28:25 AEST 1988


In article <10171 at steinmetz.steinmetz.ge.com> davidsen at crdos1.UUCP (bill davidsen) writes:
>In article <3210 at haddock.ISC.COM> karl at haddock.ima.isc.com (Karl Heuer) writes:
>My notes from the Seattle X3J11 meeting at which identifiers were
>defined states that "upper and lower case alphabetics, digits, and the
>underscore character" may be used, and that "the first character may not
>be a digit." Unless that idea has been changed the $ is not a legal
>character for an identifier.

I've found the relevant statement in 3.8.1: "[when a group is skipped]
directives are processed only through the name that determines the directive
in order to keep track of the level of nested conditionals; the rest of the
directives' preprocessing tokens are ignored, as are the other preprocessing
tokens in the group."  I read this as saying that in my example,
   #ifdef __VMS
   #ifdef foo$bar
   #endif
   #endif
the non-VMS system is obliged to stop reading after the word "ifdef" in the
second line, and NOT complain about the "$".  This also justifies my previous
statement that "#include junk" should not have provoked an error.

(Btw, since "$" isn't even a legal character in a strictly conforming program,
the VMS implementation can allow it to appear in identifiers (this is a Common
Extension, see A.6.5.2) and still be conforming.  I think.)

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list