|Pre-Parsers firstname.lastname@example.org (Jim Granville) (2000-09-08)|
|Re: Pre-Parsers email@example.com (Randall Hyde) (2000-09-09)|
|Re: Pre-Parsers firstname.lastname@example.org (2000-09-13)|
|Re: Pre-Parsers email@example.com (2000-09-15)|
|Re: Pre-Parsers firstname.lastname@example.org (2000-09-21)|
|Re: Pre-Parsers email@example.com (Hans-Bernhard Broeker) (2000-10-08)|
|Re: Pre-Parsers firstname.lastname@example.org.OZ.AU (2000-10-10)|
|Re: Pre-Parsers email@example.com (2000-10-12)|
|Re: Pre-Parsers firstname.lastname@example.org (2000-10-12)|
|From:||email@example.com.OZ.AU (Fergus Henderson)|
|Date:||10 Oct 2000 13:00:41 -0400|
|Organization:||Computer Science, University of Melbourne|
|References:||00-09-119 00-09-155 00-10-044|
Hans-Bernhard Broeker <firstname.lastname@example.org> writes:
>> #if sizeof(int)==2 ...
>> Here sizeof() must be evaluated by the preprocessor.
>'Must' is debatable, here. With equal justification, one could say
>that source that contains such lines 'must' be rejected for being
>incompatible with the definition of the language it's supposed to be
and our moderator replies:
>[What definition would that be? ANSI/ISO C certainly permits sizeof in
>preprocessor expressions. -John]
ANSI/ISO C permits the identifier `sizeof' in preprocessor expressions,
but the standard says it must not be treated as a keyword. If it is
a macro, it must be expanded, and otherwise, it must be replaced with `0'.
The same applies to the other identifier `int' in that source code.
If neither `sizeof' nor `int' are defined as macros, the condition must
expand to `0(0)==2', which is a syntax error, and so the
implementation must report a diagnostic.
The main reason for this is to allow the C preprocessor to be
implemented as completely separate pass from the C compiler, since
that is the way it was traditionally done. Some C compilers which
have an integrated preprocessor do support `sizeof' and such like
in `#if' conditions, as an (incompatible) extension to standard C.
Fergus Henderson <email@example.com> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger firstname.lastname@example.org | -- the last words of T. S. Garp.
[Oops. Sorry about that. -John]
Return to the
Search the comp.compilers archives again.