title: storing state in a c++ dll
body: <p>Im having issues on how to store state in a dll in c++. What i currently have is something like this:</p>
  
  <pre><code>#ifndef FOO
  #define FOO
  
  #ifdef BUILD_DLL
    #define DECLSPEC __declspec(dllexport)
  #else
    #define DECLSPEC __declspec(dllimport)
  #endif
  
  namespace FOO
  {
      extern "C"
      {
          DECLSPEC bool initialize();                    
          DECLSPEC void addSomething();
          DECLSPEC void removeSomething();
          DECLSPEC void shutDown();  
      }
  }
  
  #endif // FOO
  </code></pre>
  
  <p>Now i want my dll to be able have some sort of state. For example i want the stuff that get's added by addSomething() to be stored in a std::vector inside the dll and be able to acess that same vector from removeSomething(). Since my dll just exports a set of functions, i don't really see a clean way to do that. The only ting that currently comes to my mind are global variables inside the dll. Is there a better solution than that? I kind of want to avoid using global variables even if they are only inside the dll.</p>