I want to find the _Bool
definition on my system, so for systems where it's missing I can implement it. I've seen various definitions for it here and on other sites, but wanted to check on the system for the definitive definition.
Slight problem, in that I can't find where _Bool is defined or even stdbool.h
mussys@debmus:~$ find /usr/include/* -name stdbool.h /usr/include/c++/4.3/tr1/stdbool.h
And grep
for _Bool
on /usr/include/*
and /usr/include/*/*
does not find it either.
So where is it?
Using the system header file stdbool. h allows you to use bool as a Boolean data type. true evaluates to 1 and false evaluates to 0 .
h was added to allow users the obvious name. That way, if your code didn't have a home-brewed bool , you could use the built in one. So do indeed use stdbool. h if you aren't bound to some existing home-brewed bool .
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 C programming language, as of C99, supports Boolean arithmetic with the built-in type _Bool (see _Bool). When the header <stdbool. h> is included, the Boolean type is also accessible as bool .
_Bool
is a built-in type, so don't expect to find a definition for it in a header file, even a system header file.
Having said that, guessing your system from the paths that you are searching, have you looked in /usr/lib/gcc/*/*/include
?
My "real" stdbool.h
lives there. As expected it #define
s bool
to be _Bool
. As _Bool
is a type native to the compiler there's no definition for it in the header file.
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