This is not covered in standard C ++, however, regular desktop OS provides the opportunity for this. Windows has structured exception handling (SEH) for which appropriate compiler extensions are available, and POSIX provides signal processing.
As a rule, I would say that you should not catch processor exceptions - they occur only if your program is listening, and at this moment it is time to crack the debugger, and not continue.
You cannot use the same approach - even in assembler. These funds are provided by the OS - when the CPU throws an exception, it goes to the OS to decide what to do with it, and not in user mode. Not only that, but I would say that SEH and signal processing are easily different from each other to guarantee fundamentally different approaches when used in code, so a simple #ifdef will not cut it off.
setjmp and longjmp can only work for “signals” raised by user mode code, not the OS level.
Puppy
source share