Export (0) Print
Expand All
Expand Minimize
3 out of 7 rated this helpful - Rate this topic

Compiler Warning (level 1) C4297

Error Message

'function' : function assumed not to throw an exception but does

A function contains a nothrow declaration and one or more throw statements. To resolve C4297, do not attempt to throw exceptions in functions that are declared with nothrow or to remove the nothrow specification.

For more information on exception specifications, see Exception Specifications. Also, see /EH (Exception Handling Model) for information on how to modify exception handling behavior at compile time.

This warning is also generated for __declspec(dllexport) functions marked extern "C", even if they are C++ functions.

The following sample generates C4297:

// C4297.cpp
// compile with: /W1 /LD
void __declspec(nothrow) f1()   // declared nothrow
// try the following line instead
// void f1()
{
   throw 1;   // C4297
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.