#pragma handler (OS/2, Windows)

Description

The #pragma handler directive registers an exception handler for a function.

Syntax

The function is the name of the function for which the exception handler is to be registered.

In a source file that will be compiled with the VisualAge C++ compiler, the function specified does not need to be declared before being specified in the pragma. If the function specified is an overloaded function or a member function, there is a risk that the pragma will override the compiler-generated names. This will create problems during linking.

The #pragma handler directive generates the code at compile time to install the VisualAge C++ exception handler _Exception before starting execution of the function. The pragma also generates code to remove the handler at function exit.

In C++, #pragma handler will allow the specification of a user defined handler function other than _Exception.

You must use this directive whenever you change library environments or enter a user-created DLL.

Note: If you are using the subsystem libraries, the _Exception function is not provided. To use the #pragma handler directive in a subsystem, you must provide your own exception handler named _Exception. Also:
Under the OS/2 platform, your exception handler must have _System linkage.
Under the Windows platform, your exception handler must have __cdecl linkage.

For example,

#pragma handler(func1)
#pragma handler(func2)


Preprocessor Directives - An Overview
Preprocessor Directive - #pragma


#pragma linkage (C, OS/2, Windows)
Link Options