You can use signal handlers and operating system exception handlers alone and in combination. Both signal and exception handling are implemented in C++ as they are in C. While exception handling offers additional functionality, signal handling is generally simpler. Exception handlers can be complex to write and difficult to debug, but creating your own has these advantages:
Exception Handlers and C++ Exceptions
You can combine C++ exception handling and operating system
exception handling in the same program, provided the program does
not have an operating system exception handler that overrides the
default behavior for an unidentified exception. You should always
avoid using such an exception handler in programs that use C++
exception handling, because the results can be unpredictable.
When Special Handling is Required
Floating point exceptions and two classes of library functions,
math functions and critical functions require special
exception handling. Operating system exceptions that occur
in all other library functions are treated as though they
occurred in regular user code.
If your program links with DLLs that link to more than one library environment, you must take steps to ensure that the right handler is called.
Exception handling has particular benefits in multithreaded programs and programs that use system DLLs.
![]()
Signals and Exceptions
Signal and Exception Handlers in
Multithread Programs
Signal and Exception Handlers
in DLLs
![]()
Write or Register a Signal Handler
Write or Register an Exception Handler
![]()
Exception Handling for
Floating-Point Exceptions