How to get the benefits of /EHa with /EHsc, on a particular function?

327 views Asked by At

If I know that a particular extern "C" function in my program (say, RaiseException) is the only function that raises SEH exceptions, and I want them converted to C++ exceptions, is there any way for me to "selectively enable" /EHa for that function, so that the exceptions get converted to CStructured_Exception without bloating or slowing down the rest of the program as normally caused by /EHa?

1

There are 1 answers

1
exacerbatedexpert On BEST ANSWER

There's obviously no compiler option to do that. Maybe:

void RaiseException() {
   __try {
      // do something that might throw here...
   }

   __except(EXCEPTION_EXECUTE_HANDLER) {   
      throw std::exception("structured exception");
   }
}