c++ - Private class variable requiring pointer? -
i'm putting c++ class, i'm running error can fix, don't quite understand.
i'm trying utilize next header (main.h):
#include <git2.h> class test { public: private: git_repository gitrepo; };
and next file (main.cpp):
#include "main.h" int main(int argc, char *argv[]){ test test; }
but giving me "test::gitrepo' uses undefined struct 'git_repository'". struct isn't undefined though, because if utilize pointer struct instead of struct itself...
git_repository * gitrepo;
...it compiles fine.
the type declaration git_repository follows:
typedef struct git_repository git_repository;
i grepped entire include tree, , that's typedef or struct definition in code. suggest actual struct definition hidden within of actual library implementation, not included in header?
because compiler see's git_repository
incomplete type. compiler cannot see definition of construction git_repository
treats incomplete type. means cannot inquire compiler operation needs compiler know size or layout of structure. can still declare pointer construction because pointers structures have same size irrespective of construction is.
if need create instance of construction compiler must see definition of construction , must include header defines type.
c++ qt
No comments:
Post a Comment