Solved

bool vs. BOOL

Posted on 1998-06-24
7
806 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 10 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now