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<>的上面,這樣寫,可以避免很多問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM