problem with C++ keyword true
lrtaylor@micron.com
lrtaylor@micron.com
Mon Sep 27 16:24:00 GMT 2004
Well, that may be a bug. Than again, if this is a large program (and
you didn't write all of it), I'm wondering if someone went and #define'd
true, overriding the C++ definition of it...
Also, don't forget that you don't actually have to do the comparison.
You can simply do this:
if (george)
{
<snip>
If george evaluates to any non-zero value, it will be considered to be
true.
Thanks,
Lyle
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Steve Bliss
Sent: Monday, September 27, 2004 4:50 AM
To: gcc-help@gcc.gnu.org
Subject: problem with C++ keyword true
I'm using avr-gcc version 3.4.1 to compile C++.
Here's the problem:
bool george = true;
if(george == true)
{
// never gets here
}
else
{
// always gets here
}
In other words, the expression (george == true) is always false. Isn't
this
a compiler bug?
For whatever it's worth, the value of george is 0x01 and the value of
true
seems to be 0xff.
More information about the Gcc-help
mailing list