C++ alternative tokens in the preprocessor
Gabriel Dos Reis
Gabriel.Dos-Reis@cmla.ens-cachan.fr
Tue Jul 18 13:55:00 GMT 2000
Zack Weinberg <zack@wolery.cumb.org> writes:
| On Tue, Jul 18, 2000 at 10:34:32AM +0200, Gabriel Dos Reis wrote:
| > Zack Weinberg <zack@wolery.cumb.org> writes:
| >
| > | On Tue, Jul 18, 2000 at 09:42:06AM +0200, Martin v. Loewis wrote:
| > | > Upon re-reading the standard, it occured to me that 'and', 'bitor'
| > | > etc. are not keywords in C++; they are digraphs. As the result, the
| > | > following conditional should be accepted
| > | >
| > | > #define a 1
| > | > #define b 2
| > | > #if a and b
| > | > int i=0;
| > | > #endif
| > |
| > | Interesting. Where can I find that in the C++ standard?
| >
| > Please take a look at subclause 2.5. (page 12).
|
| Okay, here is the $64,000 question. Is this legal C++?
|
| #define a 1
| #define b 2
|
| #define and && !
| #if a and b
| #error got here
| #endif
|
| If it is allowed to define 'and', etc. as macros, then the
| preprocessor doesn't need to know about these at all except for the
| #if expression parser. If it isn't, then we have to be cleverer.
It is not, 'and' is not identifier.
-- Gaby
CodeSourcery, LLC http://www.codesourcery.com
More information about the Gcc-patches
mailing list