3B2 cpp #ifdef + #include

ELIN Forsch.z. rcvie at tuvie
Thu Mar 31 22:40:08 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:
>>   #ifdef foo$bar /* a valid name, in VMS */
>
>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 believe that anything goes in a quoted
>filename."

Dollar signs are valid parts of identifiers in VAXC, as many routines
in the run-time library use them (and the routines have to be accessible
from VAXC either). Thus these names are normally *hidden* be `#ifdef vms'
constructs if portability is needed (as are other system dependent things).
Noone would really expect cpp to claim about it.

K&R seem to have had this point of view, although not clearly stating:

"If the checked condition is true then any lines between #else and #endif
 are ignored. If the checked condition is false then any lines between
 the test and an #else or, lacking an #else, the #endif, are ignored.
	These constructions may be nested."

ANSI, however, states explicitely:

"Each directive's condition is checked in order. If it evaluates to
 false (zero), the group that it controls is skipped: directives are
 processed only through the name that determines the directive 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. ..."

		Dietmar Weickert,
			ALCATEL-ELIN Research Center, Vienna, Austria.



More information about the Comp.lang.c mailing list