Share via


nothrow

Microsoft and C++ Specific —>

This is a __declspec extended attribute which 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.

See for more information.

END Microsoft and C++ Specific