Of Standards and Inventions: A Cautionary Tale
Walter Bright
bright at Data-IO.COM
Sat Apr 9 03:43:44 AEST 1988
In article <10949 at mimsy.UUCP> chris at mimsy.umd.edu (Chris Torek) writes:
< On a machine with 32 bit |long|s and two's complement
< arithmetic, what is the type of -2147483648 in the preprocessor?
<As noted earlier, the only
<way to remove the unsigned attribute is to use a cast. But since the
<preprocessor explicitly disallows casts, there is no way to get
<-2147483648!
I don't understand why ANSI C doesn't allow casts and sizeofs in
preprocessor expressions. The
only restriction that is reasonable is disallowing typedef'd types
in the cast or the sizeof, because then the preprocessor has to have
information from the compiler's symbol table. Also, preprocessor
expressions are computed as longs by default instead of ints.
In fact, preprocessor expressions should follow the
SAME rules as C expressions.
In my compiler, they follow the same rules because it's the same code!
More information about the Comp.lang.c
mailing list