Created Date: 04 Jan, 2024 12:42
Last Modified Date: 13 Feb, 2024 16:29


Issue:

When attempting to debug a C++ Mako project built with MFC (Microsoft Foundation Class Library), an Assert is displayed similar to this example:

Solution:

We discovered that MFC #defines the ‘new’ keyword to do debugging magic, making the memory un-releasable by anything other than MFC.

This is why the assert occurs only in the debug build.

The workaround is to create an alternative configuration, based on the Release build. By default, Visual Studio generates symbols files (.pdb) even for a Release build, so it is still possible to debug: set breakpoints, single-step through code etc. Follow these steps:

  1. Display your project's property pages
  2. Click Configuration Manager (button, top right)
  3. Select <New...> from the Active Solution Configuration manager combo
  4. Give the new configuration a name, such as "RelWithDebInfo" or whatever you like. Copy the settings from Release.
  5. Under Configuration Properties => C/C++, set Optimization to Disabled (/Od) 

Build with this configuration and you can continue to debug.