您的位置:首页 > 其它

gcc:编译 expected declaration specifiers or ‘...’ before

2017-02-19 09:59 4199 查看
这种错误,一般是头文件include混乱造成的。

 

实例:

In file included from ftpp.h:6:0,

                    from ftpp.c:2:

parser.h:17:30: 错误:expected declaration specifiers or ‘...’ before ‘tFtpMsg’

parser.h:19:30: 错误:expected declaration specifiers or ‘...’ before ‘tFtpMsg’

 

parser.h:

 ================

#ifndef _PARSER_H_

#define _PARSER_H_

#include "ftpp.h"     //这里等于包含来自己

 

 

ftpp.h:

================

#ifndef _FTPP_H

#define _FTPP_H

#include "sockwrapper.h"

#include "common.h"

#include "parser.h"   //这里是错误包含,ftpp.h中用不到parser.h,如果ftpp.h中用到parser.h中定义到数据

                           //那么将parser.h中定义的部分放到ftpp.h中,

                            //然后将此条包含删除,避免循环包含!!!!!!!!!

#include <pthread.h>

 

parser.c:

================

#include "parser.h"   

#include "sockwrapper.h"

#include <string.h>

 

++++++++++++++++++

有一个好习惯得养成,#include "" 最好写在#include<>的上面,这样写,可以避免很多问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐