error: expected declaration specifiers or '...' before xxx(xxx是函数形参)
来源:互联网 发布:用php做购物网站案例 编辑:程序博客网 时间:2024/06/09 20:23
今天汗颜了一大阵
早上,在编译我的源代码的时候竟然不通过编译,上个星期六也出现了这种情况,当时不知道怎么弄的后来又通过编译了,可能是原来的.o文件没有make clean 还保存在那里,以至于蒙过去了,我的代码也已经用SVN提交了,真是致命(污染了项目的源码)。好在我当即解决了。
编译出错提示:
……………………
error: expected declaration specifiers or '...' before 'WEB_VOICE_VAR'
情形描述:
结构体变量WEB_VOICE_VAR var 定义在 a.c 中,a.h声明 了 extern WEB_VOICE_VAR var.我在b.c 想使用a.c中已经赋值了的var结构体的成员的值,于是在b.h中#include"../../a.h",然,出现了上面的编译错误。
原因分析:
网上搜索,讨论的不少,越看越茫然。
可能原因是
b.h中#include "../../a.h" 而a.h中的函数声明中用到了b.h中的结构体或者typedef,那么就会出现在包含a.h的时候b.h中的结构体或者typedef还没有声明,从而陷入错误.
解决办法:
将#include "../../a.h"直接放到b.c中,当再次make 的时候,pass了
- error: expected declaration specifiers or '...' before xxx(xxx是函数形参)
- 【错误笔记】error: expected declaration specifiers or '...' before XXX
- linux error: expected declaration specifiers or '...' XXX
- error: expected declaration specifiers or '...' before错误
- error: expected declaration specifiers or '...' before ***
- error expected declaration specifiers or ‘...’ before ‘SElemType’
- error: expected declaration specifiers or '...' before错误
- expected declaration specifiers or ‘...’ before
- error: expected declaration specifiers or ‘...’ before string constant
- 【错误】error: expected declaration specifiers or ‘...’ before string constant
- gcc:编译 expected declaration specifiers or ‘...’ before
- expected declaration specifiers or '...' before string constant
- error: expected declaration specifiers before ‘return’
- error: expected declaration specifiers or '...' 问题解决
- 安装PHP时 jpeglib.h:954: error:expected declaration specifiers or ‘...’ before ‘FILE’ 错误解决
- /sysroot/usr/include/search.h:19: error: expected declaration specifiers or '...' before '__free_fn_
- /home/zhang/code/hello/hello.c:3: error: expected declaration specifiers or ‘...’ before string cons
- expected declaration specifiers or '...' before string constant编译告警
- 归并排序算法
- Linux常用工具--vim的语法高亮和缩进设置
- 代理模式整理
- C++类模板
- 本文来自《香格里拉天空下的经济学漫想》一书作者 彭萦 投稿。
- error: expected declaration specifiers or '...' before xxx(xxx是函数形参)
- Excel显示及下载
- 关于vCalendar / to-do / vEvent的区别
- POCO中Event同步对象的POSIX实现
- 关于430与晶振的信息
- 交叉表、行列转换和交叉查询经典
- MFC文档序列化
- 调停者模式整理
- 比较全的fourcc含义