【发布时间】:2016-11-22 08:17:23
【问题描述】:
我有以下包含封装类型结构定义的文件结构,当我尝试访问该结构的成员时,我收到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 在其他地方定义。
【问题讨论】:
-
inlcude foo_encoder.c 到代码中,它将起作用。之后让我知道,并给出完整的答案。另一种方法是在新的 .h 文件中完整定义 struct FooEncoder 并包含它。
-
您正试图访问
MyFooInst*类型变量的成员。但是,在您提供的代码中没有MyFooInst类型的定义。
标签: c++