为BOOL本地C类型? [英] Is bool a native C type?

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

问题描述

我已经注意到,Linux内核code使用布尔,但我认为这是布尔C ++的类型。布尔是一个标准的C扩展(例如,ISO C90)或GCC的扩展?

I've noticed that the Linux kernel code uses bool, but I thought that bool was a C++ type. Is bool a standard C extension (e.g., ISO C90) or a GCC extension?

推荐答案

布尔存在于当前C - C99,但不是在C89 / 90

bool exists in the current C - C99, but not in C89/90.

在C99本机类型实际上是所谓 _Bool ,而布尔是定义一个标准库宏 stdbool.h (这果然解析为 _Bool )。类型的对象 _Bool 持有0或1,而真正也可以从 stdbool.h 。

In C99 the native type is actually called _Bool, while bool is a standard library macro defined in stdbool.h (which expectedly resolves to _Bool). Objects of type _Bool hold either 0 or 1, while true and false are also macros from stdbool.h.

这篇关于为BOOL本地C类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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