CEGUI_DEFINE_WR_MODULE throws MSVC warning C4297

Create issue
Issue #137 invalid
Former user created an issue

Automatic migration. Original reporter: "kbluck"

Compiling source modules that include macro CEGUI_DEFINE_WR_MODULE causes a level 1 warning on MSVC 8.0:

"warning C4297: 'registerFactory' : function assumed not to throw an exception but does. The function is extern "C" and /EHc was specified."

Reproducibility: always

Additional information: According to MSDN:

"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. This warning is also generated for declspec(dllexport) functions marked extern "C", even if they are C++ functions."


Apparently, /EHsc (the "c" qualifier, that is) tells the compiler to assume that extern "C" functions never throw an exception, which this one does. Since this means extern "C" are treated equivalent to nothrow, any throw here will result in a call to unexpected(), which will probably go on to abend the program.

Using just /EHs will change that assumption to allow throws from extern "C", but this might result in undefined behavior for other processes that attempt to link with the DLL and do not assume the same exception behavior.

Comments (1)

  1. Log in to comment