To bool or not to bool in C/C++ ?
-
Since coders - both C and C++ -cannot AGREE which way is up, I'll continue to evaluate MOST BINARY conditions explicitly to its binary values. Problem solved. Now let's solve Mac or Windows next. Have s well day,ya'l.
-
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" :-) 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 :-)
In vino veritas
-
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" :-) 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 :-)
In vino veritas
-
... with only one exception: if someone agrees with him! :^)