title: use static class variable/function across dlls
body: <p>I need help access global functions across DLLs/main program. I have a class Base</p>
  
  <p>Base.h</p>
  
  <pre><code>#ifdef MAIN_DLL
  #define DECLSPEC __declspec(dllexport)
  #else
  #define DECLSPEC __declspec(dllimport)
  #endif
  
  
  class Base {
  private:
      DECLSPEC static Filesystem * filesystem;
      DECLSPEC static Logger * logger;
      DECLSPEC static System * system;
  
  public:
  
      static void setFilesystem(Filesystem * filesystem_);
      static void setApplication(Application * application_);
      static void setLogger(Logger * logger_);
      static void setSystem(System * system_);
  
      static Filesystem * fs() { return filesystem; }
      static Logger * log() { return logger; }
      static System * sys() { return system; }
  
  };
  </code></pre>
  
  <p>main.cpp (main application) (MAIN_DLL is predefined here)</p>
  
  <pre><code>Filesystem * Base::filesystem = 0;
  Logger * Base::logger = 0;
  System * Base::system = 0;
  </code></pre>
  
  <p>When I access <strong>from the dll</strong>:</p>
  
  <pre><code>System * system = Base::sys();
  if(system == 0) std::cout &lt;&lt; "Error";
  </code></pre>
  
  <p>Thanks,
  Gasim</p>