This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
iso646 and 'and'
- To: gcc-bugs at gcc dot gnu dot org, zack at wolery dot cumb dot org
- Subject: iso646 and 'and'
- From: Benjamin Kosnik <bkoz at cygnus dot com>
- Date: Fri, 21 Jul 2000 18:14:48 -0700
libstdc++-v3 has a testfile that looks at ciso646 conformance.
This code:
#ifdef and
test = false;
#endif
previously did not cause any problems. Now:
warning: #ifdef with invalid argument
What's the deal? How come things like 'and' give warnings but stuff
like 'int' (also a keyword) don't give me a problem?
-benjamin
here's the testfile:
// 2.11 Keywords
// alternative representations
// and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq
// C 2.2.2 Header <iso646.h>
// The tokens (as above) are keywords and do not appear as macros in <ciso646>.
// Test for macros.
bool test01()
{
bool test = true;
#ifdef and
test = false;
#endif
#ifdef and_eq
test = false;
#endif
#ifdef bitand
test = false;
#endif
#ifdef bitor
test = false;
#endif
#ifdef compl
test = false;
#endif
#ifdef not_eq
test = false;
#endif
#ifdef not_or
test = false;
#endif
#ifdef or
test = false;
#endif
#ifdef or_eq
test = false;
#endif
#ifdef xor
test = false;
#endif
#ifdef xor_eq
test = false;
#endif
#ifdef DEBUG_ASSERT
assert(test);
#endif
return test;
}
// Equivalance in usage.
bool test02()
{
bool test = true;
bool arg1 = true;
bool arg2 = false;
int int1 = 45;
int int2 = 0;
test &= arg1 && int1;
test &= arg1 and int1;
test &= (arg1 && arg2) == (arg1 and arg2);
test &= (arg1 && int1) == (arg1 and int1);
#ifdef DEBUG_ASSERT
assert(test);
#endif
return test;
}
int main(void)
{
test01();
test02();
return 0;
}