C中_Bool和bool类型的区别? [英] Difference between _Bool and bool types in C?

查看:38
本文介绍了C中_Bool和bool类型的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下 C 中 _Boolbool 数据类型的区别是什么?

Can anyone explain me what is the difference between the _Bool and bool data type in C?

例如:

 _Bool x = 1;
  bool y = true;

  printf("%d", x);
  printf("%d", y);

推荐答案

这些数据类型是在 C99 中添加的.由于 bool 在 C99 之前未被保留,因此它们使用 _Bool 关键字(已保留).

These data types were added in C99. Since bool wasn't reserved prior to C99, they use the _Bool keyword (which was reserved).

bool_Bool 的别名.基本上,包括 stdbool.h 标头表明您的代码没有问题,标识符 bool 被保留",即您的代码不会将它用于其自己的目的(类似于标识符truefalse).

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

这篇关于C中_Bool和bool类型的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆