Ilya Melamed Ilya Melamed - 1 year ago 117
C++ Question

Member access into incomplete type error

I have the following files structure that contain the definition of a struct an encapsulating type, when I try to access a member of the struct, I get the

Member access into incomplete type
error. What is the problem?


#include "foo.h"
struct FooEncoder {
int A;
int B;
foo_int32 C;


extern "C" {
typedef struct FooEncoder FooEncoder;


typedef struct MyFooEncInst FooEncInst;

#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

is defined in another place.

Answer Source

You're asking for a member in the FooEncoder struct which isn't visible anywhere in your file. This looks similar to a pimpl idiom.

In order to have your code aware of FooEncoder's structure you need to either

#include "foo_encoder.c"

in your file (I quite don't like this solution and you didn't post the full code either) or move your struct definition elsewhere in a header file and include that one (recommended).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download