Of Standards and Inventions: A Cautionary Tale

Walter Bright bright at Data-IO.COM
Tue Apr 12 04:09:41 AEST 1988


In article <7637 at brl-smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
<In article <1525 at dataio.Data-IO.COM< bright at dataio.UUCP (Walter Bright) writes:
<<I don't understand why ANSI C doesn't allow casts and sizeofs in
<<preprocessor expressions. ...
<<In my compiler, they follow the same rules because it's the same code!
<We didn't want to mandate that the preprocessor be integrated into the
<language parser proper.  I agree that the language would be nicer if
<it WERE so integrated, but for historical reasons it wasn't.

What I proposed didn't mandate this. What I proposed was to COPY (or use
#ifdef's) the code for the expression parser into the preprocessor code.
This would then ensure that the behavior was the same. The only thing
that the preprocessor's parser couldn't handle would be symbol table
lookups of things that aren't macros. It could and should be able to
handle things like:

#if sizeof(long) != sizeof(int)

and:

#if (unsigned long) 1.2345e+6 > WHATEVER

variations of which I've wanted to do many times.



More information about the Comp.lang.c mailing list