Partilhar via


nothrow (C++)

Microsoft Specific

A __declspec extended attribute which can be used in the declaration of functions.

return-type __declspec(nothrow) [call-convention] function-name ([argument-list])

Remarks

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. Given the following preprocessor directive, the three function declarations below are equivalent:

#define WINAPI __declspec(nothrow) __stdcall 

void WINAPI f1();
void __declspec(nothrow) __stdcall f2();
void __stdcall f3() throw();

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

See Synchronous Exception Handling for more information.

END Microsoft Specific

See Also

Reference

__declspec

C++ Keywords