我注意到Linux内核代码使用bool,但我认为bool是C++类型.bool是标准C扩展(例如,ISO C90)还是GCC扩展?
在下面的例子中,我试图扫描boolean变量类型的值.当我在GCC编译时,我得到以下警告,
warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘_Bool *’ [-Wformat=]
scanf("%d",&b);
Run Code Online (Sandbox Code Playgroud)
码:
#include <stdio.h>
#include <stdbool.h>
int main()
{
bool b;
scanf("%d",&b);
printf("%d\n",b);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,bool中是否有任何格式说明符C?