bool vs. BOOL

Are bool (standard C++) and BOOL (defined in Visual C++) interchangable?
LVL 2
VEngineerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
galkinConnect With a Mentor Commented:
BOOL defined as int, it means 32 bit. bool is one bit. sometimes if you convert BOOL to bool you can get compiler warning
0
 
VEngineerAuthor Commented:
Is there a way I can redefine all BOOL to be bool so I can be consistent?
0
 
galkinCommented:
#ifdef BOOL
#undef BOOL
#endif

#define BOOL bool
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
VEngineerAuthor Commented:
Is there a way I can redefine all BOOL to be bool so I can be consistent?
0
 
VEngineerAuthor Commented:
Oops, accidental repost.
0
 
VEngineerAuthor Commented:
I know 32 bit int is 4 bytes, but is bool a bit or a byte?  I always thought a byte was the lowest unit that could be addressed...
0
 
nietodCommented:
The size of a bool is implimentation defined.  But it is pretty safe to say that it is at least a byte and ususally not more than the size of an int.  you can use sizeof(bool) to get the size of a bool for a particular implimentation.   For VC 5 it returns 1  meaning 1 byte not bit.  You don't want to redefine window's BOOLs to bool.  You could change things on "your side" that is, in your programs, but windows would still expect a 32 bit BOOL, not a 1 byte bool.  Also they have different logic.  A bool should specify only 0 or 1 in binary.  A BOOL can be and 32 bit binary value.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.