BOOL and bool

what's the difference between BOOL and bool?
thanks
[60 byte] By [doxdici] at [2007-11-19 6:38:42]
# 1 Re: BOOL and bool
BOOL is internally defined as integer type,

it will takes values of TRUE(1) and FALSE(0),

where as bool is one of the data type .
dwurity at 2007-11-11 0:30:32 >
# 2 Re: BOOL and bool
what's the difference between BOOL and bool?Take a look at this thread ( http://www.dev-archive.com/forum/showthread.php?t=256205) - and this one ( http://www.dev-archive.com/forum/showthread.php?t=256642).
gstercken at 2007-11-11 0:31:25 >
# 3 Re: BOOL and bool
More specifically.

bool is the instrinsic c/c++ boolean type but is defined as zero = false and non-zero = true. Microsoft introduced the BOOL (integer) data type to improve portability to other platforms such as Alpha. Defining a BOOL type means that for each platform the most appropriate platform specific boolean data type could be used by defining BOOL as whatever was required for each platform.
Bob Sheep at 2007-11-11 0:32:35 >
# 4 Re: BOOL and bool
BOOL is a typedef (typedef int BOOL; ) where as bool is a type.
bool has only values "true" and "false" whereas BOOL can have any int value
--> have a look for "TRUE" / "FALSE" (#define FALSE 0, #define TRUE 1)

Hope this helps

Holi
Holi the Rob at 2007-11-11 0:33:33 >
# 5 Re: BOOL and bool
Hey Holi -

bool type can have any values (intger) along with true and false.. ...
dwurity at 2007-11-11 0:34:32 >
# 6 Re: BOOL and bool
Hey Holi -

bool type can have any values (intger) along with true and false.. ...
If I understand you right, you mean that you can do the following?

bool bValue = 5;

If I do this, I get the following warning:

...(...): warning C4305: 'initializing' : truncation from 'const int' to 'bool'

You could do, but ...
Holi the Rob at 2007-11-11 0:35:31 >
# 7 Re: BOOL and bool
If I understand you right, you mean that you can do the following?

bool bValue = 5;

If I do this, I get the following warning:

...(...): warning C4305: 'initializing' : truncation from 'const int' to 'bool'

You could do, but ...

No need to worry with the message, coz the use of bool is simply to say true or false, if the value is other than 0 its true !
dwurity at 2007-11-11 0:36:37 >
# 8 Re: BOOL and bool
No need to worry with the message, coz the use of bool is simply to say true or false, if the value is other than 0 its true !

Okay, I guess this depends on personal preference how to write code. I don't like to program warnings (no-warning policy). That's why I use BOOL for values other than true/false. I know that one can do almost anything with C/C++ by casting, but I don't think it's the most proper way.
Holi the Rob at 2007-11-11 0:37:33 >
# 9 Re: BOOL and bool
Of course if you're using MFC it's far preferable to use BOOL and not 'bool' otherwise you end up having to convert all over the place...

Darwen.
darwen at 2007-11-11 0:38:41 >
# 10 Re: BOOL and bool
One other point...

A BOOL (signed int really) will act slightly diffferently than a bool in the following case...

BOOL testBool = -1; //this actually evaluates to TRUE
testBool++; //now this evaluates to FALSE because it is equal to 0

bool testbool = true; // obviously true
testbool++; // will always be true no matter how many times you increment it
// the bool type will never roll from true to false from increment operator.

Just a minor point.

Have a great day!
krmed at 2007-11-11 0:39:33 >