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.

C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539 © 2008-2017.
If you may any questions please contact us: