c++ - Error: variable '*' has initializer but incomplete type and one other -


i know there couple other questions on specific question, nothing can find on seems work, i'm posting specific code.

here code:

#ifndef __memory_tracker_h__ #define __memory_tracker_h__  #include <unordered_map>  namespace cige { namespace memory { class cige_api memorytracker { protected: typedef struct allocrecord {     size_t bytes;     std::string filename;     size_t line;     std::string func;      allocrecord() :         bytes(0), line(0)     { }     allocrecord(size_t sz, const char* file, size_t ln, const char* fun) :         bytes(sz), line(ln)     {         if (file)             filename = file;         if (fun)             func = fun;     } } allocrecord;  std::string m_leakfilename; bool m_dumptoconsole; typedef std::unordered_map<void*, allocrecord> allocmap; allocmap m_allocationmap;  size_t m_totalallocations; bool m_recordenable;  protected: void reportleaks();  memorytracker() :     m_leakfilename("cigememory.log"), m_dumptoconsole(true), m_totalallocations(0), m_recordenable(true) { }  public: void setreportfilename(const std::string& name) {     m_leakfilename = name; } const std::string& getreportfilename() const {     return m_leakfilename; } void setreporttoconsoleoutput(bool b) {     m_dumptoconsole = b; } bool getreporttoconsoleoutput() const {     return m_dumptoconsole; } void setrecordenable(bool b) {     m_recordenable = b; } bool getrecordenable() const {     return m_recordenable; }  size_t gettotalmemoryallocated() const {     return m_totalallocations; }  void _recordalloc(void* ptr, size_t sz, const char* file = nullptr, size_t ln = 0, const char* fun = nullptr); void _recorddealloc(void* ptr);  ~memorytracker() {     reportleaks(); }  static memorytracker& get(); }; } }  #endif // __memory_tracker_h__ 

i'm getting: variable 'cige::memory::cige_api cige::memory::memorytracker' has initializer incomplete type @ line class declaration. i've looked on , cant find answers have fixed issue.

i'm having error expected '}' or ',' or ';' before 'protected' @ line protected, right above struct.

any either of these 2 errors appreciated.

edit: cige_api defined in separate file (which included), __declspec(dllexport).

edit2: fixed problem (see answer below). code::blocks derping out pretty bad.

looks cige_api not defined. compiler try resolve variable declaration class type variable {initializer-list}, type cige_api , variable memorytracker.

in other words, syntactically you're predeclaring cige_api type , creating variable of type instead of defining class.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -