[LAD] Mixed boolean & numbers

David Robillard d at drobilla.net
Thu Sep 1 01:28:45 UTC 2016

On Sat, 2016-08-27 at 16:49 +0100, Will Godfrey wrote:
> I'm finding quite a lot of occasions where variables defined as 'bool' are
> sometimes being set with true or false and other times 0 or 1. On one occasion
> there is something like x = n + {boolean variable}
> This last one seems quite unsafe to me as I didn't think the actual value of
> true and false was guaranteed.
> Am I being overly cautious or should I change them all to one form or the other?

This is fine.  The C/C++ standards guarantee that a bool, when converted
to an integer, is 1 or 0 (the pedantically correct way of saying this
depends on which standard/revision, but effectively that sums it up).

It's pretty convenient/elegant at times.  Personally, I exploit it when
that's the case, but be more explicit if it has potential to be


More information about the Linux-audio-dev mailing list