__declspec(nothrow)

From RAD Studio
Jump to: navigation, search

Go Up to Keywords, Alphabetical Listing Index


Category

Modifiers (C++), Keyword Extensions, Storage Class Specifiers (C++)

Syntax

__declspec( nothrow ) declarator

This is a __declspec extended attribute that can be used in the declaration of functions. This attribute tells the compiler that the declared function and the functions it calls never throw an exception. With the synchronous exception handling model, now the default, the compiler can eliminate the mechanics of tracking the lifetime of certain unwindable objects in such a function, and significantly reduce the code size.

The following three declarations are equivalent:

#define WINAPI __declspec(nothrow) __stdcall 
void WINAPI foo1();
void __declspec(nothrow) __stdcall foo2();
void __stdcall foo3() throw();

Using void __declspec(nothrow) __stdcall foo2(); has the advantage that you can use an API definition, such as the one illustrated by the #define statement, to easily specify nothrow on a set of functions. The third declaration, void __stdcall foo3() throw();, is the syntax defined by the C++ standard.

See also