|
|
C99 adds the header <stdbool.h>, which supports the _Bool data type. Although it does not define any functions, it does define these four macros:
Macro | Expands To |
---|---|
bool | _Bool |
true | 1 |
false | 0 |
_ _bool_true_false_are_defined | 1 |
The reason that C99 specified _Bool rather than bool 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. The same reasoning goes for true and false. However, for new programs, it is best to include <stdbool.h> and then use the bool, true, and false macros. One advantage of doing so is that it allows you to create code that is compatible with C++.
|
|