Share via


C++ Exception Handling

 

The latest version of this topic can be found at C++ Exception Handling.

The C++ language provides built-in support for throwing and catching exceptions. When programming in C++, you should almost always use the built-in C++ exception support as described in this section.

To enable C++ exception handling in your code, use /EHsc.

In This Section

This discussion on C++ exception handling includes:

Support for Earlier MFC Exceptions

As of version 4.0, MFC began using the C++ exception handling mechanism. Although you are encouraged to use C++ exception handling in new code, MFC version 4.0 and later retains the macros from previous versions of MFC so that old code will not be broken. The macros and the new mechanism can be combined as well. For information on mixing macros and C++ exception handling and on converting old code to use the new mechanism, see the articles Exceptions: Using MFC Macros and C++ Exceptions and Exceptions: Converting from MFC Exception Macros. The older MFC exception macros, if you still use them, evaluate to C++ exception keywords. See Exceptions: Changes to Exception Macros in Version 3.0.

See Also

Exception Handling