你好,我遇到了一个问题。 这是我的头文件,包含结构定义和方法原型。
typedef struct SymbolTable
{
...some elements
}ST;
extern struct ST STable;
void Symbol_Put(ST *S, char* sym);
在我的c程序中,我使用:
#include "myheader.h"
struct ST STable;
在方法中我使用头文件中的方法。
...body of the method...
int id = Symbol_Put(STable,sym_name);
不幸的是我收到了这个错误:
‘STable’ has an incomplete type
int s = Symbol_Put(STable,sym_name)
我不明白出了什么问题。我很高兴能指出我犯了错误的地方。谢谢!
答案 0 :(得分:4)
代码中没有struct ST
。只有struct SymbolTable
和ST
。
将声明更改为
extern ST STable;
和
的定义ST STable;
Symbol_Put
期望指针作为第一个参数,但您传递ST
。用
int id = Symbol_Put(&STable,sym_name);