Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1861482
  • 博文数量: 152
  • 博客积分: 3730
  • 博客等级: 上尉
  • 技术积分: 3710
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-02 14:36
个人简介

减肥,运动,学习,进步...

文章分类

全部博文(152)

文章存档

2016年(14)

2015年(17)

2014年(16)

2013年(4)

2012年(66)

2011年(35)

分类: C/C++

2012-08-26 14:43:20

今天写了一段比较简单的C语言程序,但是在编译的时候却遇到了一个不怎么常见的错误,特此做一个简单的总结。
 
我采用gcc编译的过程中出现了如下的一些错误:
[gong@Gong-Computer hashmap]$ gcc -g testlist.c list.c -o testlist
In file included from testlist.c:3:0:
list.h:28:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘create_list’
list.h:29:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘insert_listnode’
list.h:30:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘delete_listnode’
In file included from list.c:4:0:
list.h:28:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘create_list’
list.h:29:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘insert_listnode’
list.h:30:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘delete_listnode’
list.c:6:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘create_listnode’
list.c:19:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘create_list’
list.c:33:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘insert_listnode’
list.c:76:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘delete_listnode’
这种错误在我前面写代码的时候很少看见,我也不知道是怎么了,然后我又采用g++的编译器进行了一次编译,竟然通过了。所以我觉得肯定是编译器存在问题。
 
这个让我有些不知所措,通过查找网页,发现了这个问题出现的原因。
 
出现这种错误是因为bool类型错误,因为我在程序中返回了false,true以及bool类型,但是在C语言中是不存在布尔类型的数据的,这就是出现错误的原因。
 
找到的原因通过宏定义即可解决上面出现的问题:
#define bool int
#define true 1
#define false 0
 
添加好这几个宏定义以后,编译器竟然没有问题了。
阅读(20230) | 评论(1) | 转发(2) |
给主人留下些什么吧!~~

文峰聊书斋2017-12-29 17:18:52

error: expected \'=\', \',\', \';\', \'asm\' or \'__attribute__\' before \'hidg_plat_driver_remove\'
因为函数定义部分static int __devexit hidg_plat_driver_remove(struct platform_device *pdev)的__devexit是多余的,未定义的。