C++ and Structured Exception Handling

wRTOS supports ISO-standard C++ exception handling (catch/throw), Windows Structured Exception Handling (SEH) API, and C frame-based exception handling (try/except/finally), all as defined by the Windows Platform SDK.

In this topic:

Note: For more information on the APIs referenced in this chapter, see the wRTOS SDK Help.

C++ Support

wRTOS supports the Visual C++ language, with some restrictions discussed in the note below. RTSS supports all C++ features usable in a Windows C++ wRTOS API console application, including new/delete operators and exception handling.

Note: wRTOS does not claim support for all C++ libraries. Support is limited to libraries that depend upon the set of Windows functions supported in the RTSS environment. See the Matrix of C++ Standard Template Library Calls for more information.

Structured Exception Handling

RTSS supports Microsoft Structured Exception Handling and ISO-standard C++ exception handling, as described by the Windows Platform SDK, including:

EXCEPTION_BREAKPOINT
EXCEPTION_SINGLE_STEP
EXCEPTION_ACCESS_VIOLATION
EXCEPTION_ILLEGAL_INSTRUCTION
EXCEPTION_FLT_DENORMAL_OPERAND
EXCEPTION_FLT_DIVIDE_BY_ZERO
EXCEPTION_FLT_INEXACT_RESULT
EXCEPTION_FLT_INVALID_OPERATION
EXCEPTION_FLT_OVERFLOW
EXCEPTION_FLT_UNDERFLOW
EXCEPTION_INT_DIVIDE_BY_ZERO
EXCEPTION_DOUBLE_FAULT

Using Structured Exception Handling

To use Structured Exception Handling (SEH) in an RTSS application, the application must be linked with the Microsoft C Runtime libraries that contain run-time support for the SEH frame-based exception handlers.

Differences Between Windows and RTSS Exception Handling

The RTSS implementation follows Windows SEH semantics where possible. This section describes the differences.

UnhandledExceptionFilter

Windows UnhandledExceptionFilter semantics provide the option to disable the exception-related dialog box pop-up via SetErrorMode with the SEM_NOGPFAULTERRORBOX flag. On an exception, RTSS always displays a pop-up saying that the application has been frozen or unloaded.

Exception caused by a thread

When a thread of a multithreaded application causes an exception in Windows, the system displays a dialog box. Until the user responds to the box, other threads of the application continue running. Once the user has responded, all threads of the application terminate.

RTSS acts differently; it freezes (or unloads, depending on how the Subsystem is configured in the wRTOS Settings) all threads of a process whenever any of them gets an exception, and produces an informational pop-up. This behavior is safer and more intuitive in the RTSS context. You can, however, emulate the Windows behavior by using per-thread unhandled exception filter functions.

Nested exceptions and collided unwinds

RTSS follows Windows rules for nested exceptions and "collided" unwinds, with a few minor differences:

General User Notes for Exception Handling