相关疑难解决方法(0)

bool是原生C型吗?

我注意到Linux内核代码使用bool,但我认为bool是C++类型.bool是标准C扩展(例如,ISO C90)还是GCC扩展?

c gcc boolean linux-kernel

248
推荐指数
8
解决办法
31万
查看次数

C中有bool的格式说明符吗?

在下面的例子中,我试图扫描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

c boolean

9
推荐指数
1
解决办法
9424
查看次数

标签 统计

boolean ×2

c ×2

gcc ×1

linux-kernel ×1