Export (0) Print
Expand All
1 out of 5 rated this helpful - Rate this topic

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])

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.