pete <> writes:
> kerravon wrote:
>>
>> According to 6.8 of C90, #if takes a constant expression.
>>
>> According to 6.4 of C90, the sizeof operator is part of a constant
>> expression.
>
> The preprocessor can't read keywords.
>
>
> ISO/IEC 9899: 1990
> 6.8.1 Conditional inclusion
> Constraints
>
> identifiers (including those lexically identical to keywords)
> are interpreted as described below;83
>
> 83 Because the controlling constant expression
> is evaluated during translation phase 4,
> all identifiers either are or are not macro names
> -- there simply are no keywords, enumeration constants, etc.
That quotation is from the C99 standard, not the C90 standard.
In both C90 and C99, handling of identifiers in a #if directive is
described as (C90 6.8.1, C99 6.10.1p3):
After all replacements due to macro expansion and the defined
unary operator have been performed, all remaining identifiers are
replaced with the pp-number 0, and then each preprocessing token
is converted into a token.
Technical Corrigendum 3 (incorporated into n1256) changes this to:
After all replacements due to macro expansion and the defined
unary operator have been performed, all remaining identifiers
(including those lexically identical to keywords)
are replaced with the pp-number 0, and then each preprocessing
token is converted into a token.
I've marked the added text by putting it on a separate line.
This is a clarification, not a change, since keywords are lexically
identifiers. See DR #305,
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_305.htm>.
(It would be nice if the TC documents referred back to the DRs.)
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"