Topic: Preprocessor expressions with undefined symbols


Author: AllanW@my-dejanews.com
Date: 1998/09/10
Raw View
In article <sa3hfyh34jd.fsf@gameboy.gia.rwth-aachen.de>,
  Stefan Rupp <struppi@gia.rwth-aachen.de> wrote:
[snip]
> #if _MSC_VER >= 1000
[snip]

> what if the identifier _MSC_VER isn't defined at all? Does the expression
> evaluate to false or does it result in an error?  I can't find anything in
> the CD2 about that question.



Author: Stefan Rupp <struppi@gia.rwth-aachen.de>
Date: 1998/09/09
Raw View
Good afternoon,

consider the following preprocessor directive (which is generated by
some obscure C++ compiler automatically):

#if _MSC_VER >= 1000
...
#endif // _MSC_VER >= 1000

what if the identifier _MSC_VER isn't defined at all? Does the expression
evaluate to false or does it result in an error?  I can't find anything in
the CD2 about that question.

Doei,
     struppi

--
Dipl.-Inform. Stefan H. Rupp
Geodaetisches Institut der RWTH Aachen         Email: struppi@acm.org
Templergraben 55, D-52062 Aachen, Germany      Tel.:  +49 241 80-5295
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: James Kuyper <kuyper@wizard.net>
Date: 1998/09/09
Raw View
Stefan Rupp wrote:
>
> Good afternoon,
>
> consider the following preprocessor directive (which is generated by
> some obscure C++ compiler automatically):
>
> #if _MSC_VER >= 1000
> ...
> #endif // _MSC_VER >= 1000
>
> what if the identifier _MSC_VER isn't defined at all? Does the expression
> evaluate to false or does it result in an error?  I can't find anything in
> the CD2 about that question.
>
> Doei,
>      struppi
>

In section 16.1, "Conditional inclusion", paragraph 4, it states that
| replacement, the behavior is undefined.  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

Since 0 < 1000, when _MSC_VER isn't defined, the expression evaluates to
false.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]