這種錯誤,一般是頭文件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<>的上面,這樣寫,可以避免很多問題。
