bool vs. BOOL

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

[Webinar] Streamline your web hosting managementRegister Today

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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
All Courses

From novice to tech pro — start learning today.