_Bool和布尔类型C的区别? [英] Difference between _Bool and bool types in C?
问题描述
谁能给我解释一下什么是用C _Bool和布尔数据类型之间的区别吗?
例如:
_Bool X = 1;
布尔Y =真实的; 的printf(%D,X);
的printf(%D,Y);
在C99中添加这些数据类型。由于布尔
不是之前C99保留,他们使用 _Bool
关键字(这是保留的)。
布尔
是 _Bool
如果您有一个别名 stdbool.h
。基本上,包括 stdbool.h
头是一个迹象,你的code是与标识符确定布尔
是保留,即你的code将不会使用它来达到自己的目的(类似的标识符真正
和假
)。
Can anyone explain me what is a difference between _Bool and bool data type in C ? For example
_Bool x = 1;
bool y = true;
printf("%d", x);
printf("%d", y);
These data types were added in C99. Since bool
wasn't reserved prior to C99, they use the _Bool
keyword (which was reserved).
bool
is an alias for _Bool
if you include stdbool.h
. Basically, including the stdbool.h
header is an indication that your code is OK with the identifier bool
being 'reserved', i.e. that your code won't use it for its own purposes (similarly for the identifiers true
and false
).
这篇关于_Bool和布尔类型C的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!