title: Using a singleton across DLL boundary
body: <p>I have a legacy project which has a singleton class like this:</p>
  
  <pre><code>class Singleton
  {
  public:
      static Singleton&amp; Instance() 
      {
          static Singleton inst;
          return inst;
      }
  
      void foo();
  };
  </code></pre>
  
  <p>The project uses a DLL which needs to use the same class (part of the source is shared between the hosting application and the DLL, so the DLL has access to <code>Singleton</code>). However, <code>Instance</code> (naturally) returns a different instance for DLL, and a different one for the hosting application. This obviously causes problems. </p>
  
  <p>Is there a way to use the same instance between the DLL and the hosting process? (let's assume that binary compatibility is not an issue.)</p>