title: Using C++ DLLs with different compiler versions
body: <p>This question is related to <a href="https://stackoverflow.com/questions/232926/how-to-make-consistent-dll-binaries-across-vs-versions">"How to make consistent dll binaries across VS versions ?"</a></p>
  
  <ul>
  <li>We have applications and DLLs built
  with VC6 and a new application built
  with VC9. The VC9-app has to use
  DLLs compiled with VC6, most of
  which are written in C and one in
  C++.</li>
  <li>The C++ lib is problematic due to
  name decoration/mangling issues.</li>
  <li>Compiling everything with VC9 is
  currently not an option as there
  appear to be some side effects.
  Resolving these would be quite time
  consuming.</li>
  <li>I can modify the C++ library, however it must be compiled with VC6.</li>
  <li>The C++ lib is essentially an OO-wrapper for another C library. The VC9-app uses some static functions as well as some non-static.</li>
  </ul>
  
  <p>While the static functions can be handled with something like</p>
  
  <pre><code>// Header file
  class DLL_API Foo
  {
      int init();
  }
  
  extern "C"
  {
      int DLL_API Foo_init();
  }
  
  // Implementation file
  int Foo_init()
  {
      return Foo::init();
  }
  </code></pre>
  
  <p>it's not that easy with the non-static methods.</p>
  
  <p>As I understand it, <a href="https://stackoverflow.com/questions/232926/how-to-make-consistent-dll-binaries-across-vs-versions#232959">Chris Becke's</a> suggestion of using a COM-like interface won't help me because the interface member names will still be decorated and thus inaccessible from a binary created with a different compiler. <em>Am I right there?</em></p>
  
  <p>Would the only solution be to write a C-style DLL interface using handlers to the objects or am I missing something?
  In that case, I guess, I would probably have less effort with directly using the wrapped C-library.</p>