Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

bool vs. BOOL

Posted on 1998-06-24
7
Medium Priority
?
881 Views
Last Modified: 2012-06-21
Are bool (standard C++) and BOOL (defined in Visual C++) interchangable?
0
Comment
Question by:VEngineer
  • 4
  • 2
7 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 20 total points
ID: 1166569
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
 
LVL 2

Author Comment

by:VEngineer
ID: 1166570
Is there a way I can redefine all BOOL to be bool so I can be consistent?
0
 
LVL 7

Expert Comment

by:galkin
ID: 1166571
#ifdef BOOL
#undef BOOL
#endif

#define BOOL bool
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:VEngineer
ID: 1166572
Is there a way I can redefine all BOOL to be bool so I can be consistent?
0
 
LVL 2

Author Comment

by:VEngineer
ID: 1166573
Oops, accidental repost.
0
 
LVL 2

Author Comment

by:VEngineer
ID: 1166574
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
 
LVL 22

Expert Comment

by:nietod
ID: 1166575
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question