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

这种错误,一般是头文件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<>的上面,这样写,可以避免很多问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值