Click here to Skip to main content
16,015,072 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: The latter is the uppercase version of the former. Pin
Rajesh R Subramanian20-May-08 3:52
professionalRajesh R Subramanian20-May-08 3:52 
GeneralRe: The latter is the uppercase version of the former. Pin
toxcct20-May-08 3:53
toxcct20-May-08 3:53 
GeneralRe: The latter is the uppercase version of the former. Pin
Rajesh R Subramanian20-May-08 3:54
professionalRajesh R Subramanian20-May-08 3:54 
JokeRe: The latter is the uppercase version of the former. Pin
Cedric Moonen20-May-08 3:55
Cedric Moonen20-May-08 3:55 
GeneralRe: The latter is the uppercase version of the former. Pin
toxcct20-May-08 3:56
toxcct20-May-08 3:56 
JokeRe: The latter is the uppercase version of the former. Pin
Rajesh R Subramanian20-May-08 3:58
professionalRajesh R Subramanian20-May-08 3:58 
JokeRe: The latter is the uppercase version of the former. Pin
CPallini20-May-08 3:59
mveCPallini20-May-08 3:59 
AnswerRe: bool and BOOL [modified] Pin
toxcct20-May-08 3:33
toxcct20-May-08 3:33 
if you're coding in C, bool just don't exist (I prefer mention it, even it's obvious).

in C++, bool is a native type. it weights 1 byte and takes the values 0b00000001 (true) or 0b00000000 (false).

you can assign an integer to a bool. if it is different from 0, it equals the value "true", and will be automatically converted into 0b00000001 anyway.

BOOL is different. it is an enum type inherited from the old C days.

it's definition is like this :
enum BOOL {
    FALSE = 0,
    TRUE
};

An enum is actually an int, which mean it weights 4 bytes (on a 32 bits system).

apparently, Microsoft implements it in a different manner, so you have to be much more careful with it. for instance :
//if defined like this :
typedef int BOOL;
 
//this can be a mistake :
BOOL b = 4;
if (b == true) {
    //never enters here
    // because 4 != 1
}



modified on Tuesday, May 20, 2008 9:50 AM

GeneralRe: bool and BOOL Pin
Rajesh R Subramanian20-May-08 3:36
professionalRajesh R Subramanian20-May-08 3:36 
GeneralRe: bool and BOOL Pin
toxcct20-May-08 3:38
toxcct20-May-08 3:38 
GeneralRe: bool and BOOL Pin
Rajesh R Subramanian20-May-08 3:41
professionalRajesh R Subramanian20-May-08 3:41 
GeneralRe: bool and BOOL Pin
toxcct20-May-08 3:44
toxcct20-May-08 3:44 
GeneralRe: bool and BOOL Pin
CPallini20-May-08 3:41
mveCPallini20-May-08 3:41 
GeneralRe: bool and BOOL Pin
toxcct20-May-08 3:45
toxcct20-May-08 3:45 
GeneralOf course. Pin
CPallini20-May-08 3:50
mveCPallini20-May-08 3:50 
GeneralRe: Of course. Pin
toxcct20-May-08 3:52
toxcct20-May-08 3:52 
GeneralRe: bool and BOOL Pin
Cedric Moonen20-May-08 3:54
Cedric Moonen20-May-08 3:54 
GeneralRe: bool and BOOL Pin
toxcct20-May-08 3:55
toxcct20-May-08 3:55 
QuestionRe: bool and BOOL [modified] Pin
Jhony george20-May-08 3:48
Jhony george20-May-08 3:48 
AnswerRe: bool and BOOL [modified] Pin
CPallini20-May-08 3:57
mveCPallini20-May-08 3:57 
GeneralRe: bool and BOOL Pin
toxcct20-May-08 4:00
toxcct20-May-08 4:00 
GeneralRe: bool and BOOL Pin
CPallini20-May-08 4:13
mveCPallini20-May-08 4:13 
GeneralRe: bool and BOOL Pin
Rajesh R Subramanian20-May-08 4:15
professionalRajesh R Subramanian20-May-08 4:15 
GeneralRe: bool and BOOL Pin
CPallini20-May-08 4:40
mveCPallini20-May-08 4:40 
NewsRe: bool and BOOL Pin
Jhony george20-May-08 17:47
Jhony george20-May-08 17:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.