RAD Studio |  |

__declspec(nothrow)

Category

Modifiers, Keyword extensions, Storage class specifiers

Syntax

Copy Code

    __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:

Copy Code

    #define WINAPI __declspec(nothrow) __stdcall

Copy Code

    void WINAPI foo1();

Copy Code

    void __declspec(nothrow) __stdcall foo2();

Copy Code

    void __stdcall foo3() throw();

Using void __declspec(nothrow) __stdcall foo2(); has the advantage that you can use an API definition, such as the 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.

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