我注意到Linux内核代码使用bool类型,但我以为bool类型是c++类型。bool是标准的C扩展名(例如,ISO C90)还是GCC扩展名?
当前回答
stdbol .h是c99年引入的
其他回答
C99在stdbool.h中定义了bool, true和false。
_Bool是C99中的关键字:它指定类型,就像int或double一样。
6.5.2 2声明为_Bool类型的对象 是否大到足以存储值0 和1。
/* Many years ago, when the earth was still cooling, we used this: */
typedef enum
{
false = ( 1 == 0 ),
true = ( ! false )
} bool;
/* It has always worked for me. */
没有这样的东西,可能只是int的宏
stdbol .h是c99年引入的