The C99 standard of the C programming language defines the _Bool
data type as a macro for another data type (as the language isn't able to deal with a type safe boolean).
Is the _Bool
a macro for unsigned char
, unsigned int
or some other data type?
_Bool
is a separate integere type that according to the C Standard. _Bool
is a keyword of the C language.
2 An object declared as type _Bool is large enough to store the values 0 and 1.
_Bool
is unsigned integer type.
The type _Bool and the unsigned integer types that correspond to the standard signed integer types are the standard unsigned integer types.
And there should be mentioned that
— The rank of _Bool shall be less than the rank of all other standard integer types.
The _Bool
type is a new type appearing in the standard C99.
It is an unsigned integer type.
Its range of values it has to be able to hold the values 0 and 1.
The range of values of _Bool
is contained in the range of values of any other unsigned integer type.
The keyword _Bool
is used instead of bool
because the standard rationale suppose that there exists in the existing practice (before 1999) several and different uses of the identifier bool
(as a macro or well as a typedef).
The standard header <stdbool.h>
defines the macro bool
as meaning exactly _Bool
.
Also, the (macro) constants true
and false
are defined as being 1 and 0 respectively.
Although the intent is to use the word bool
, the programer can choose to use or not the standard type _Bool
or well to give his own definition of bool
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With