Structured Exceptions Under Win32 (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Exception Handling in C++Builder

Win32 supports C-based structured exception handling (SEH) that is similar to standard C++ exception handling. There are some key differences, however, that require careful use when they are mixed with C++ code that is exception-aware.

Keep the following in mind when using structured exception handling in C++Builder applications:

  • C-structured exceptions can be used in C++ programs.
  • C++ exceptions cannot be used in a C program because C++ exceptions require that their handler be specified by the catch keyword, and catch is not allowed in a C program.
  • An exception generated by a call to the RaiseException function is handled by a try/__except (C++) or __try/__except (C) block. (You can also use try/__finally or __try/__finally blocks. See Syntax of Structured Exceptions (C++). All handlers of try/catch blocks are ignored when RaiseException is called.
  • Exceptions that are not handled by the application don't result in a call to terminate, but are instead passed to the operating system (in general, the end result is termination of the process).
  • Exception handlers do not receive a copy of the exception object, unless they request it.

You can use the following C exception helper functions in C or C++ programs:

C++Builder does not restrict the use of UnhandledExceptionFilter function to the except filter of __try/__except or try/__except blocks. However, program behavior is undefined when this function is called outside of a __try/__except or try/__except block.

Topics

See Also