cmp
cmp copied to clipboard
cleanup: Start of no-implicit-bool compliance; use prefix-increment.
Semantics of postfix-increment are to return the value it had before the increment, encouraging code like f(..., b++)
, which is better written as f(..., b); ++b;
to avoid doing too many possibly mutating operations in one statement/expression.
I've put one of the no-implicit-bool cleanups in this PR, because it's the only one that requires CMP_NULL
and an addition to the CI to continue supporting C++ as a compile target for cmp.c (it does today, and I don't want to break that). There are a number of implicit bool conversions, some of which are probably bugs, so I'll send a separate PR to fix those.
I try to keep the C++-isms to a minimum in CMP and I'm not convinced of the benefits here. I did pull in the CI changes (thanks!), but I think unless there are errors in C++ compilers that can only be fixed by switching from idiomatic C to idiomatic C++ I don't think this is necessary. Could be convinced though!
Ok, I've reverted the CMP_NULL
change for now, keeping the prefix-incr change and moving a local variable to a deeper scope (still C89 compatible).
OK I can live with that, thanks for doing it :)