Can anyone explain me what is the difference between the _Bool
and bool
data type in C?
For example:
_Bool x = 1;
bool y =
There is no difference.
bool
is a macro that expands to _Bool
in stdbool.h
.
And true
is a macro that expands to 1 in stdbool.h
These data types were added in C99. Since bool
wasn't reserved prior to C99, they use the _Bool
keyword (which was reserved).
bool
is an alias for _Bool
if you include stdbool.h
. Basically, including the stdbool.h
header is an indication that your code is OK with the identifier bool
being 'reserved', i.e. that your code won't use it for its own purposes (similarly for the identifiers true
and false
).