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<>的上面,這樣寫,可以避免很多問題。
轉載于:https://www.cnblogs.com/mingChou/archive/2013/01/16/wdewf.html
總結
以上是生活随笔為你收集整理的gcc:编译 expected declaration specifiers or ‘...’ before的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 获取文件扩展名函数
- 下一篇: MariaDB Java Client