Afficher un message
Vieux 27/05/2008, 23h30   #21
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: preprocessing statements

In article <lnd4n7qx3n.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
>"D. Power" <powerd@pcisys.net.invalid> writes:
>> In article <g1hn6u$nhj$1@canopus.cc.umanitoba.ca>,
>> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:


>>> #ifdef if
>>> /* this section will *not* be compiled, because the macro if is -not-
>>> defined. */
>>> #endif


>> This seems to be an odd use of a keyword, but it seems to work.


>"if" isn't a keyword as far as the preprocessor is concerned; it's
>just another identifier. Though I agree that the use of "if" in this
>context is ugly.


Keith is correct on both counts -- the preprocesor doesn't know
anything about "keywords" or library functions, or about any of
the types other than the basic arithmetic types of various
sizes (and, I suppose, size_t).

And yes, it is ugly -- its name was chosen specifically to illustrate
the point that *everything* that looks like an identifier (but which
is not a macro), will have 0 substituted in an #if preprocessor statement.

Further example:

#if the + world + is *round* why + do + we + ~ fall + off + while + we + stand + on + our + heads + at + night ? Author : unknown
/* something */
#endif


If I haven't overlooked anything, that should be compilable even if
nothing is #define'd, even though it appears to use the C keywords
if and do and while .
--
"When a scientist is ahead of his times, it is often through
misunderstanding of current, rather than intuition of future truth.
In science there is never any error so gross that it won't one day,
from some perspective, appear prophetic." -- Jean Rostand
  Réponse avec citation
 
Page generated in 0,06021 seconds with 9 queries