Why does C use the word _Bool
to define boolean values? Whereas they use the word float
for floats and not _Float
?
Furthermore, wh
As for ...
Furthermore, why does
bool
have to be included, why isn't part of the basic functionality, likefloat
?
... I observe that although you need to include stdbool.h
to get bool
, that's a convenience and C++-compatibility feature, not an essential. bool
is an alias for _Bool
, and in C99 and later you have _Bool
automatically, but even that is non-essential. In C, any integer or pointer value can be interpreted as a boolean, with 0
or NULL
being interpreted as false and all other values being interpreted as true. This was how boolean values were handled in C from the beginning, and it still works in implementations conforming to the latest standard.
In fact, type _Bool
itself is just a special case of this very behavior: it is an integer type whose minimal requirements are that it be able to represent the values 0 and 1. In boolean context, it works just the same as any other integer type.