The attribute Attribute

The <stdbool.h> Header

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++.




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

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net