RAD Studio |  |

set_terminate

Header File

except.h

Syntax

typedef void (*terminate_handler)();

terminate_handler set_terminate(terminate_handler t_func);

Description

set_terminate lets you install a function that defines the program's termination behavior when a handler for the exception cannot be found. The actions are defined in t_func, which is declared to be a function of type terminate_handler. A terminate_handler type, defined in except.h, is a function that takes no arguments, and returns void.

By default, an exception for which no handler can be found results in the program calling the terminate function. This will normally result in a call to abort. The program then ends with the message Abnormal program termination. If you want some function other than abort to be called by the terminate function, you should define your own t_func function. Your t_func function is installed by set_terminate as the termination function. The installation of t_func lets you implement any actions that are not taken by abort.

Return Value

The previous function given to set_terminate will be the return value.

The definition of t_func must terminate the program. Such a user-defined function must not return to its caller, the terminate function. An attempt to return to the caller results in undefined program behavior. It is also an error for t_func to throw an exception.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!