|
|
C99 includes the _Bool data type, which is capable of storing the values 1 and 0 (i.e., true/false). _Bool is an integer type, and it differs from the C++ keyword bool. Thus, C99 and C++ are incompatible on this point. Also, C++ defines the built-in Boolean constants true and false, but C99 does not. However, C99 adds the header <stdbool.h>, which defines the macros bool, true, and false. Thus, C/C++-compatible code can be easily created.
The reason that _Bool rather than bool was specified as a keyword is that many existing C programs had already defined their own custom versions of bool. By defining the Boolean type as _Bool, C99 avoids breaking this preexisting code. However, for new C programs, it is best to include <stdbool.h> and then use the bool macro.
|
|