somefile.h的內容:C代碼的編譯錯誤
#ifndef __SOMEFILE_H
#define __SOMEFILE_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _table_t
{
void (*somefunction1)();
void (*somefunction2)(int a);
void (*somefunction3)(int a, int *b);
}table_t;
void doSomething1();
void doSomething2();
#ifdef __cplusplus
} // error at this line: expected constructor, destructor, or type conversion before '(' token
#endif
#endif
上面顯示的是代碼片段和錯誤,當我編譯我在Linux上的代碼,我得到。沒有任何抱怨,相同的代碼在Windows上編譯得很好。請幫我解決這個問題。我在互聯網上搜索了很多,但沒有找到正確的解決辦法。謝謝。
關於源文件:
all.h is a header file which includes:
#include "header1.h"
#include "header2.h"
#include "header3.h"
#include "somefile.h"
這裏是somefile.c
#include "all.h"
#include "header4.h"
jumptable_t jumptable_a =
{
a_function1();
a_function2(int a);
a_function3(int a, int *b);
}
//more code
void function1()
{
a_function1();
}
void function2(int a)
{
a_function2(a);
}
void function3(int a, int *b)
{
a_function3(a, b);
}
void doSomething1()
{
}
void doSomething2()
{
}
假設這個頭文件被包含在一個C++源文件中,那麼它上面是否還有其他頭文件? –
是的,這個頭文件包含在C++源文件中。 – RRR
不,上面沒有其他頭文件。 – RRR