我有以下文件结构包含一个结构的封装类型的定义,当我尝试访问结构的成员,我得到Member access into incomplete type
错误。问题是什么?成员访问到不完整类型错误
foo_encoder.c:
#include "foo.h"
//...
struct FooEncoder {
int A;
int B;
foo_int32 C;
//...
}
foo.h中:
extern "C" {
typedef struct FooEncoder FooEncoder;
//...
}
foo_interface.h:
typedef struct MyFooEncInst FooEncInst;
foo_interface.cc:
#include "foo_interface.h"
#include "foo.h"
//...
struct MyFooEncInst {
FooEncoder* encoder;
};
//...
MyFoo_Encode(FooEncInst* inst,...) {
//...
if (d > inst->encoder->C) { // This is where I get the error
//...
}
foo_int32
在另一个地方所定义。
将foo_encoder.c包含到代码中,它将起作用。之后让我知道,并会给出完整的答案。另一种方法是在新的.h文件中对struct FooEncoder进行全面定义并包含它。 – Nick
您正尝试访问“MyFooInst *”类型变量的成员。但是,在您提供的代码中没有“MyFooInst”类型的定义。 – sigy