C编译时`true'+undeclared+(first+use+in+this+function)
来源:互联网 发布:昆明百度seo推广 编辑:程序博客网 时间:2024/04/29 15:36
原文:http://liuzhigong.blog.163.com/blog/static/178272375201121664244437/
在编译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就可以的。
- 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)
- 关闭Android应用程序
- 在Android中通过jni方式使用编译好的FFmpeg库-Android中使用FFmpeg媒体库(二)
- socket+结构在+linux+中的定义
- 一个使用FFmpeg库读取3gp视频的例子-Android中使用FFmpeg媒体库(三)
- 写在创业的路上:如何从无到有的打造一个产品
- C编译时`true'+undeclared+(first+use+in+this+function)
- 投资人和创业者应学到的最重要的经验
- Maven里Xerces依赖冲突导致Spring加载xml出错
- experiment:+tinyXML
- 互联网公司创业的7道槛
- VIM常用命令
- 今夜,我辗转反侧
- 加拿大学者:乔布斯不是爱迪生 其实没那么伟大
- 在Windows+Phone中进行3D开发之一坐标系+.