Mixing C++ and SEH exception handling

The RaiseException Windows function will throw an SEH exception. The first parameter is the exception code and the second indicates if the process can continue after this exception is handled (0 means it can). The third and fourth parameters give additional information about the exception. The fourth parameter is a pointer to an array with these additional parameters and the number of parameters is given in the third parameter.

With /EHa, you can write code like this:

    try      {         RaiseException(1, 0, 0, nullptr);     }     // legal code, but don't do it     catch(...)     {         cout << "SEH or C++ exception caught" << endl;     }

The problem with this code is that it handles all SEH exceptions. This is quite dangerous because ...

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.