C++ exceptions
This section describes the programming considerations for coding C++ exceptions in your application on the z/TPF system.
The z/TPF system supports only application-defined exceptions. System errors and program checks are handled by the operating system and are not shown to the application.
Exceptions can be thrown from a function and caught by another function in the same CSO; for example, an exception can be thrown by a CSO, but caught by another CSO that resides in the ECB program nesting level (PNL). All z/TPF programs that reside in the PNL between the current program and the program that contains a catch clause are dropped from the nesting level. z/TPF enter/back processing performs all cleanup that is associated with dropping a program from a nesting level.
- If you do not want the z/TPF system to issue a system error for an unhandled exception, create a local modification of the cabort.c program that omits the serrc_op_ext call.
- If you want your application to process unhandled exceptions, set up your own terminate handler function by using the
set_terminate function. For example, you can create the
myterminate function and then register the
myterminate function by calling
std::set_terminate(myterminate).
If you code a throw block in a destructor, the corresponding try and catch blocks must also be in the scope of the destructor or the results are unpredictable.