_Bool data type of C99

余生长醉 提交于 2019-12-06 04:23:11

_Bool is a separate integere type that according to the C Standard. _Bool is a keyword of the C language.

2 An object declared as type _Bool is large enough to store the values 0 and 1.

_Bool is unsigned integer type.

The type _Bool and the unsigned integer types that correspond to the standard signed integer types are the standard unsigned integer types.

And there should be mentioned that

— The rank of _Bool shall be less than the rank of all other standard integer types.

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 keyword _Bool is used instead of bool because the standard rationale suppose that there exists in the existing practice (before 1999) several and different uses of the identifier bool (as a macro or well as a typedef).

The standard header <stdbool.h> defines the macro bool as meaning exactly _Bool.
Also, the (macro) constants true and false are defined as being 1 and 0 respectively.

Although the intent is to use the word bool, the programer can choose to use or not the standard type _Bool or well to give his own definition of bool.

C99 defines a new type _Bool.

It also defines a new header file stdbool.h that includes the line:

#define bool _Bool
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!