错误描述
error: unknown type name ‘bool’; did you mean ‘_Bool’?
错误原因
未知的类型名:‘bool’, 因为在C语言标准(C89)没有定义布尔类型,所以会报错。而C99提供了一个头文件<stdbool.h>
定义了bool
,true
代表1,false
代表0。只要导入stdbool.h
,就能非常方便的操作布尔类型了。
解决方法
//添加头文件
#include <stdbool.h>
error: unknown type name ‘bool’; did you mean ‘_Bool’?
未知的类型名:‘bool’, 因为在C语言标准(C89)没有定义布尔类型,所以会报错。而C99提供了一个头文件<stdbool.h>
定义了bool
,true
代表1,false
代表0。只要导入stdbool.h
,就能非常方便的操作布尔类型了。
//添加头文件
#include <stdbool.h>