
Hello Ian,
On Sun, 25 Oct 2015 19:22:00 +0000, Ian Campbell ijc+uboot@hellion.org.uk wrote:
On Sun, 2015-10-25 at 14:22 +0100, Albert ARIBAUD wrote:
On Sun, 25 Oct 2015 12:40:45 +0000, Ian Campbell
Doesn't the bool return type already cause that to happen? (from the PoV of the caller at least)
When all is said and done, a C bool is a C int,
Not if it is a _Bool (via stdbool.h or some other way).
A _Bool is always either 0 or 1, and scalar value which is converted to a _Bool is converted to either 0 or 1.
So no, types, bool or otherwise, do not cause any implicit '!!' to happen.
I believe this is not correct when _Bool is used.
In u-boot a bool is indeed a _Bool (or at least I don't see any other typedef's and I can see various includes on stdbool.h, I therefore didn't feel the need to check how bool is arrived at in this particular file).
What you write is possibly correct for C++, but certainly not for C, for which booleans are integers, with no compiler-enforced constraint on their value domains.
Amicalement,