C编译时`true' undeclared (first use in this function)
来源:互联网 发布:数据库的架构是什么 编辑:程序博客网 时间:2024/04/29 13:22
在编译C语言时有时会遇到这样的错误提示:
`true' undeclared (first use in this function) or `false' undeclared (first use in this function)
就是说 bool, true, false 都是undeclared,原因很简单,因为真正的C中没有这些关键字,c和早期的c++里没有关键字bool,使用BOOL可以,但BOOL不是内置类型了,都是通过typedef或者宏来定义的,通常都会被定义成int类型。后来的c++出现了内置类型bool,值只能为true(1)和false(0)。
解决方法:
1、将文件名.c改为文件名.cpp,用C++方式编译则没问题
2、自己进行一个宏定义:
typedef enum __bool { false = 0, true = 1, } bool;
c90是没有bool的,因此支持c90的dev-c++当然也没有。想在c90里用bool,可以自行用宏进行定义。
c99支持bool,用支持c99的编译器例如gcc就可以的。
`true' undeclared (first use in this function) or `false' undeclared (first use in this function)
就是说 bool, true, false 都是undeclared,原因很简单,因为真正的C中没有这些关键字,c和早期的c++里没有关键字bool,使用BOOL可以,但BOOL不是内置类型了,都是通过typedef或者宏来定义的,通常都会被定义成int类型。后来的c++出现了内置类型bool,值只能为true(1)和false(0)。
解决方法:
1、将文件名.c改为文件名.cpp,用C++方式编译则没问题
2、自己进行一个宏定义:
typedef enum __bool { false = 0, true = 1, } bool;
c90是没有bool的,因此支持c90的dev-c++当然也没有。想在c90里用bool,可以自行用宏进行定义。
c99支持bool,用支持c99的编译器例如gcc就可以的。
阅读全文
0 0
- C编译时`true'+undeclared+(first+use+in+this+function)
- C编译时`true' undeclared (first use in this function)
- C编译时`true' undeclared (first use in this function)
- C编译时`true' undeclared (first use in this function)
- C编译时`true' undeclared (first use in this function)
- linux C 编译错误 error: ‘EOWNERDEAD’ undeclared (first use in this function)
- NF_IP_PRE_ROUTING’ undeclared (first use in this function)
- 'O_BINARY' undeclared (first use in this function)
- `pid_t' undeclared (first use in this function)
- qemu-2.4.0编译时出错:error: ‘XFS_IOC_ZERO_RANGE’ undeclared (first use in this function)
- Linux驱动编程编译模块时出现 error:'TASK_NORMAL' undeclared (first use in this function
- MySQL 编译出现 error: 'SSL_OP_NO_COMPRESSION' undeclared (first use in this function) 错误
- 编译minicom出现问题:error: ‘BC’ undeclared (first use in this function)
- [kernel]: error: ‘PATH_MAX’ undeclared (first use in this function)
- error: 'FILE' undeclared (first use in this function)
- error: 'FALSE' undeclared (first use in this function)
- error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function)
- error: ‘IPPROTO_RAW’ undeclared (first use in this function)
- 阿里云搭建Https域名访问
- Java用OpenOffice将word转换为PDF并预览
- 【分享】偶然
- 数组操作系列之合并按照逗号拼接,对应好URL,在利用数组遍历出来
- svn出现无法cleanup的情况
- C编译时`true' undeclared (first use in this function)
- 从有道走来的码农……
- zhx P98 a题
- 客户端软件的结构思考(一)
- 如何下架自己的 APP(APP Store)
- RPM安装和yum安装
- 机器学习之K-最近邻规则分类(KNN)算法
- Object-c数据类型
- SpringMVC中视图解析器的作用