Click here to Skip to main content
15,846,860 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: To bool or not to bool in C/C++ ? Pin
k505421-Feb-20 7:16
mvek505421-Feb-20 7:16 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan21-Feb-20 7:18
mveRichard MacCutchan21-Feb-20 7:18 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Vaclav_21-Feb-20 9:25
Vaclav_21-Feb-20 9:25 
GeneralRe: To bool or not to bool in C/C++ ? Pin
k505421-Feb-20 10:31
mvek505421-Feb-20 10:31 
AnswerRe: To bool or not to bool in C/C++ ? Pin
leon de boer21-Feb-20 12:55
leon de boer21-Feb-20 12:55 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Vaclav_22-Feb-20 6:34
Vaclav_22-Feb-20 6:34 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan22-Feb-20 7:47
mveRichard MacCutchan22-Feb-20 7:47 
GeneralRe: To bool or not to bool in C/C++ ? Pin
leon de boer23-Feb-20 6:29
leon de boer23-Feb-20 6:29 
Not only does he not realize that statement is incorrect what he plans to do is also going to give bugs.

He is going to test for the value of true by "== 1" Smile | :)

There is another subtlety that on compares with C/C++ any other value than 0 is true.
Windows and Linux both use that extensively especially on API call returns
They know a function hands back a register for a bool (not a bit) so they actively exploit it

Even consider normal things you see like
void* P = malloc(100);
if (p)
{
   // use p as it's valid
}

You can't write the true case simply ... the reality is the actual test is p != 0.

The moment you get MACROS you actually have no idea what the expansions are and he will end up doing things like
testing "p == 1" above ... which would be an amusing bug.

It's actually amusing how many problems you can create in some crazy attempt to fix a non existent problem based on total misunderstanding Smile | :)
In vino veritas


modified 23-Feb-20 11:41am.

GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan23-Feb-20 7:08
mveRichard MacCutchan23-Feb-20 7:08 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Victor Nijegorodov23-Feb-20 21:43
Victor Nijegorodov23-Feb-20 21:43 
GeneralText based mining game using if and while Pin
Chleba22519-Feb-20 11:41
Chleba22519-Feb-20 11:41 
GeneralRe: Text based mining game using if and while Pin
Stefan_Lang19-Feb-20 22:42
Stefan_Lang19-Feb-20 22:42 
GeneralRe: Text based mining game using if and while Pin
Vaclav_20-Feb-20 18:04
Vaclav_20-Feb-20 18:04 
GeneralRe: Text based mining game using if and while Pin
Chleba22521-Feb-20 21:32
Chleba22521-Feb-20 21:32 
SuggestionRe: Text based mining game using if and while Pin
David Crow24-Feb-20 4:44
David Crow24-Feb-20 4:44 
QuestionCannot open file 'hid.lib' in microsip Pin
Jafar_Ulla19-Feb-20 3:14
professionalJafar_Ulla19-Feb-20 3:14 
AnswerRe: Cannot open file 'hid.lib' in microsip Pin
CPallini19-Feb-20 3:51
mveCPallini19-Feb-20 3:51 
QuestionUse of string class in c++ Pin
Awantika Singh14-Feb-20 22:26
Awantika Singh14-Feb-20 22:26 
AnswerRe: Use of string class in c++ Pin
Victor Nijegorodov14-Feb-20 22:35
Victor Nijegorodov14-Feb-20 22:35 
AnswerRe: Use of string class in c++ Pin
Stephane Capo14-Feb-20 22:38
professionalStephane Capo14-Feb-20 22:38 
GeneralRe: Use of string class in c++ Pin
Awantika Singh15-Feb-20 5:27
Awantika Singh15-Feb-20 5:27 
GeneralRe: Use of string class in c++ Pin
Richard MacCutchan15-Feb-20 6:06
mveRichard MacCutchan15-Feb-20 6:06 
GeneralRe: Use of string class in c++ Pin
Stephane Capo15-Feb-20 22:52
professionalStephane Capo15-Feb-20 22:52 
GeneralRe: Use of string class in c++ Pin
k505416-Feb-20 4:30
mvek505416-Feb-20 4:30 
GeneralRe: Use of string class in c++ Pin
Richard MacCutchan16-Feb-20 5:58
mveRichard MacCutchan16-Feb-20 5:58 

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.