Reputation: 166
I'm working on a C++ project which links to a C library. My C++ class is as follows:
extern "C" {
struct __struct1__;
struct __struct2__;
struct __struct3__;
struct __struct4__;
}
namespace mynamespace {
class MyClass : public Parent {
public:
....
private:
....
__struct1__* s1;
__struct2__* s2;
struct __struct3__ s3;
struct __struct4__ s4;
};
}
When creating pointers like s1 and s2, everything is OK. But objects don't work well. The following error is generated:
Error using undefined struct
How can I create objects like s3 and s4?
Upvotes: 0
Views: 521
Reputation: 1723
Variable:
__struct1__ *s1
is just of type pointer (to your structure, but still just a pointer), so compiler knows exactly how much memory on stack this variable needs. But in case of:
__struct3__ s3
this variable is of type __struct3__, so without whole definition compiler does not know its size.
Upvotes: 2