Wednesday, March 23, 2016

Disabling C++ exceptions in Visual Studio 2015

When using the STL with Visual Studio 2015 – and older versions, probably –, C++ exceptions are enabled by default. To view the options specified below, first add at least one CPP file to your project.

The first thing to change on the project settings is under C/C++ code generation, enable C++ exceptions: set this to “no”.

Then, on the project settings, C/C++ preprocessor, to each configuration and platform individually, add the following preprocessor definition:
_HAS_EXCEPTIONS=0
This way you’ll be able to use the STL without the C++ exception handling mechanism.

No comments: