我有以下文件結構包含一個結構的封裝類型的定義,當我嘗試訪問結構的成員,我得到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