RAD Studio
ContentsIndex
PreviousUpNext
__declspec(nothrow)

Category 

Modifiers, Keyword extensions, Storage class specifiers 

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 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) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!