3

I am writing code in c.
I am declaring a FILE* fp at the main function (main.c).
We have other files at the project too.
So at a header file I am getting this error:
"expected declaration specifiers or ‘...’ before ‘FILE’ problem"
at this line:
void myfunct(argumenttype argument, FILE *fp);

What am I doing wrong?

Working in Linux(gedit+gcc).

4

2 回答 2

1

在使用 typedef'd 元素之前必须包含标头,否则FILE对编译器没有任何意义,并且它不知道它在看什么。

于 2011-05-28T17:30:28.357 回答
0

argumenttype 是指向结构的 typedef 类型的指针。

typedef struct testStruct testptr;
void myfunct(testptr test, FILE *fp);

我刚刚在这个头文件中包含了 stdio.h。它工作得很好。所以无论我在哪里使用依赖库的函数或 typedef 的类型,我都必须包含相关的库?

非常感谢!

于 2011-05-28T17:17:20.093 回答