Platform SDK: Debugging and Error Handling

AbnormalTermination

The AbnormalTermination function indicates whether the __try block of a termination handler terminated normally. The function can be called only from within the __finally block of a termination handler.

Note  The Microsoft C/C++ Optimizing Compiler interprets this function as a keyword, and its use outside the appropriate exception-handling syntax generates a compiler error.

BOOL AbnormalTermination(VOID);

Parameters

This function has no parameters.

Return Values

If the __try block terminated abnormally, the return value is nonzero.

If the __try block terminated normally, the return value is zero.

Remarks

The __try block terminates normally only if execution leaves the block sequentially after executing the last statement in the block. Statements (such as return, goto, continue, or break) that cause execution to leave the __try block result in abnormal termination of the block. This is the case even if such a statement is the last statement in the __try block.

Abnormal termination of a __try block causes the system to search backward through all stack frames to determine whether any termination handlers must be called. This can result in the execution of hundreds of instructions, so it is important to avoid abnormal termination of a __try block due to a return, goto, continue, or break statement. Note that these statements do not generate an exception, even though the termination is abnormal.

To avoid abnormal termination, execution should continue to the end of the block. You can also execute the __leave statement. The __leave statement allows for immediate termination of the __try block without causing abnormal termination and its performance penalty. Check your compiler documentation to determine if the __leave statement is supported.

Requirements

  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later.

See Also

Structured Exception Handling Overview, Structured Exception Handling Functions