bool vs BOOL

I was wondering what the difference is between BOOL and bool, and TRUE and true, and FALSE and false, ect. ect.
it's convenience to change BOOL to other type like "typedef BOOL DOUBLE".
but if you use 'bool',you should had to repleace everywhere 'bool' used
closed account (3pj6b7Xj)
bool is a C++ keyword BOOL is not, true & false are C++ keyword TRUE & FALSE are not. bool stands for boolean, a condition that is either true or false, a 0 or a 1.

1
2
3
4
5
6
7
8
9
bool bQuit = false;
int count = 0;

while (!bQuit)
{
     count++;

     if (count == 10) bQuit = true;
}


However, if you would have written the same code and replaced false with FALSE and true with TRUE, in some implementations they work the same way, why? Because...

1
2
#define TRUE        1
#define FALSE       0 


Not sure if this is what you wanted to know...
Last edited on
I understand that bool is a C++ keyword, and how to use it, I just want to know how BOOL is different from bool.
closed account (3pj6b7Xj)
They are the same thing except bool is for C++. BOOL is used in C...

typedef int BOOL;


In C it is a defined type of type int ...... you can store 0 or 1 or anything.....

BOOL junk; // can store a -1, true, false or 0 what ever it may be even 236 if you wanted too...

bool junk; // cannot store -1 will probably crash your program or do nothing, can only store 0 or 1.

If you are only concerned with true or false, use bool if you want to store a condition other than true or false.....not recommended but you might want to use BOOL but thats up to you...

typedef int BOOL;

can be the same was

int BOOL;

I'm speculating too much now...i'll let someone else pitch in...
Last edited on
Oh, bool = C++, BOOL = C. I got it now, thanks, this was confusing me lol.
Topic archived. No new replies allowed.