c 语言布尔值

1665阅读 0评论2010-02-09 zhxw123
分类:C/C++

在定义c函数中使用了
bool strToInt()
结果报错
test9.c:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before ‘strToInt'
后来知道
关键字bool是C++内置对布尔类型的支持。
C语言直到C99标准才增加了对布尔类型的支持,关键字为_Bool,因为bool已经被C++用了。

因此可以在程序中使用宏定义方式实现
#define bool _Bool
#define true 1
#define false 0
上一篇:linux 常用命令
下一篇:字符串转整数