Using a define that hasn't been #defined

Karl Heuer karl at haddock.ima.isc.com
Wed Oct 3 14:09:21 AEST 1990


In article <5101 at hsv3.UUCP> jls at headland.UUCP (James Seidman) writes:
>#define XYZZY 1
>...
>#if XYZZU

I've always wished that the preprocessor had used modern language-design
principles and made undefined variables illegal rather than synonyms for
zero.  Unfortunately there was a large body of code that depended on the
sloppiness, so now we're stuck with it.

The best we can hope for is to get compiler vendors to provide an option to
warn whenever an undefined symbol is used in a preprocessor conditional
(other than as the operand of defined(), of course).  Then the next step
is to get software vendors to use "#if _S_UNIX" instead of "#ifdef _S_UNIX"
to test the compilation environment--that way, it becomes possible to
distinguish "symbol not set because this isn't UNIX" from "symbol not set
because that's not the name I use to flag what you're trying to test".

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



More information about the Comp.lang.c mailing list