locked
Exception handling RRS feed

  • Question

  • In VS2008 unmanaged C++, I want to catch / report hardware exceptions.

    I have a working scheme that uses _set_se_handler.  Hardware exceptions are routed to a translate function that re-throws them as C++ exceptions.  These are caught, along with any other C++ exceptions, and reported in a uniform manner.

    However, I don't understand the behavior of the exception-related compiler options.

    In a debug build ...

    Case 1: compile all modules with /EHa (C++ and SEH).

    Under debugger, when hardware exception occurs: a) traps to debugger; b) press "continue" choice in msgbox; c) arrives at my custom translator; d) exception handled as expected.

    Case 2: compile ONLY exception handling code with /EHa; remaining with /EHsc.

    Under debugger, when exception occurs: a) traps to debugger; b) press "continue" choice in msgbox; c) re-traps to debugger.

    Obviously the exception is still being generated in Case 2 (since it gets to the debugger).  How is this different handling controlled?  Why can't I intercept the exception in Case 2.

    Friday, October 2, 2009 2:34 PM

Answers

  • Not sure if I follow, you ought to post some repro code.  But the MSDN Library docs make it clear: you must compile *all* of your code with /EHa when you use _set_se_translator().

    Hans Passant.
    • Marked as answer by nobugz Saturday, October 10, 2009 2:56 PM
    Friday, October 2, 2009 5:51 PM