当我尝试将以下函数导出为 dll 时:
extern "C" __declspec(dllexport) void some_func()
{
throw std::runtime_error("test throwing exception");
}
Visual C++ 2008 给了我以下警告:
1>.\SampleTrainer.cpp(11) : warning C4297: 'some_func' : function assumed not to throw an exception but does
1> The function is extern "C" and /EHc was specified
我需要 extern "C" 因为我使用 Qt QLibrary 来加载 dll 并解析函数名称。没有 extern "C" 就找不到 some_func() 函数。