To me it's a matter of readability/semantics. Even though a BOOL is still an integer, if a variable is clearly meant for the purpose of a bool, such as "if (bEnableThis)", then using != FALSE is redundant.
If the variable doesn't have an implicit "boolean-ness" in its name, then it may be best to write != FALSE to clarify, although in such case it may be a better choice to rename the variable itself rather than use the verbose comparison. For pointers, it's a similar matter: I understand "if (ptrSomething)" to mean != NULL. But for numbers of any type, be it int, float, or otherwise, I strongly prefer using != 0. It may sound silly, but I prefer it that way because in my head "if (myNumber)" reads as "if there is a number in this variable", and of course there is a number, it just happens to be 0, which is still a number. So although I understand the way it works, it just feels better for me to compare with != 0 and make my intention clear. On 15 November 2014 23:22, Timo Kreuzer <timo.kreu...@web.de> wrote: > Am 14.11.2014 15:32, schrieb Love Nystrom: > > > On 2014-11-14 00.41, Alex Ionescu wrote: > > I would much rather see if (f != FALSE) instead of if ( f ). > > > Well, it's certainly a valid option, and C++ compilers seem to generate > the same "CMP boolRm, 0" in both cases (though the latter could actually > generate the potentially faster and better "OR boolRm, boolRm" instead). > > "if (f != FALSE)" and "if (f)" are exactly 100% the same for the compiler. > "if (f)" is nothing but a synonym for "if (f != 0)" and FALSE is 0. Whether > it creates a CMP, or an OR or a TEST is all up to the compiler and it will > be the same in both cases. If it was not the same, there is something ... > well not neccessarily "wrong" but at least very strange with the compiler. > > > I expect some people will use the former. > Personally I much prefer the latter. > > I think both have their pros and cons. So I don't really care. > > > > _______________________________________________ > Ros-dev mailing list > Ros-dev@reactos.org > http://www.reactos.org/mailman/listinfo/ros-dev >
_______________________________________________ Ros-dev mailing list Ros-dev@reactos.org http://www.reactos.org/mailman/listinfo/ros-dev