title: MSVC Mixing Debug Code with Release Code
body: <p><strong>Motivation for Question</strong>: Generating 64-bit and 32-bit code requires two seperate full-program-compiles, and when using visual studio (as detailed below) release and debug builds are incompatible, therefore seemingly requiring another two full-program-compiles (bringing the total up to four). I would like to stick with two full-program-compiles, but I am confused. </p>
  
  <p><strong>When Debugging All I Care About Is:</strong> the global state, the stack frame, and the line-number/file of the code that caused the crash. Also, I don't care about debug info from peer-reviewed highly-stable open-source libraries; therefore, I don't need debug-info for those libraries and a release build for this libraries should be adequate.</p>
  
  <p><strong>Evidence:</strong> I know that, in VS, if you compile a debug version of an application and link it with a release version of Google Protocol Buffers, the produced code will fail due to a side-effect of mixing release/debug types. </p>
  
  <p>I would like to know if this is a side effect of using visual studio, and a certain set of compiler switches make it so.</p>
  
  <p>Secondly inspecting the build scripts/processes of opensource projects it seems that it is OK to mix code generated in debug mode with code generated in release (for example <a href="http://mumble.sourceforge.net/BuildingWindows" rel="nofollow">mumble</a>). I guess this has something to do with the distinction between release and ReleaseWithDebugInfo (term borrowed from cmake, but this is obviously expressable within Visual Studio). ReleaseWithDebugInfo is afterall an optimised version of the binary, with debugging info also generated, and therefore suitable for release. </p>
  
  <p><strong>The Questions :</strong> </p>
  
  <ol>
  <li>Could someone please explain, or provide references, as to what switches make the code incompatible.</li>
  <li>Is the ReleaseWithDebugInfo style of compiling in visual studio enough for both debug and release use-cases (according to my criteria, as explained above)? --i.e., is whatever the compiler generates in debug mode overkill or redundant ?</li>
  <li>In ReleaseWithDebugInfo mode (for my application) can I compile external dependanies in release mode (without debug info) and not have any undefined behaviour ?</li>
  </ol>