如何关闭 MSVC 中的异常处理? [英] How can I switch off exception handling in MSVC?
问题描述
有人知道如何关闭 MSVC 中的异常处理选项吗?我试图将选项启用 C++ 异常"设置为否",但收到警告:警告 C4530:使用了 C++ 异常处理程序,但未启用展开语义.指定/EHsc
.
Does anybody know how to switch off exception handling option in MSVC? I tried to set the option 'Enable C++ exceptions' to 'NO' and I got warning:
warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
.
我也想关闭异常处理程序,但我不知道如何.
I would like to switch off the exception handler, too, but I don't know how.
在我的应用程序中,我基本上需要比稳定性更高的速度,因此我选择关闭异常处理.我没有任何 try
/catch
块,但我确实使用了 STL.当我将启用 C++ 异常"选项切换为否"时,有什么方法可以消除这些警告?
In my application I basically need more speed than stability, therefore I chose switching off the exception handling. I do not have any try
/catch
blocks, but I do use STL. When I switch the option 'Enable C++ exceptions' to 'NO' is there any way how to get rid of those warnings?
推荐答案
很可能您包含一个或多个包含 try/catch 的标准 C++ 头文件.最典型的情况是 <iostream>
- 您将在文件中收到此错误,该文件仅包含一行.任何其他流标头也可以,区域设置也是如此.
Most likely you're including one or more standard C++ headers that contain try/catch. The most typical case would be <iostream>
- you will get this error on a file which consists of a single line that just includes that. Any other stream header will also do, as will locales.
如果您仔细查看错误消息,它应该引用两个文件名,而不是一个 - 您的文件和包含错误的包含文件.例如.在我的 #include
示例案例中,我得到了这个:
If you look closely at the error message, it should reference two filenames, not one - your file, and the included file with the error. E.g. in my sample case of #include <iostream>
, I get this:
except.cpp
C:Program FilesMicrosoft Visual Studio 9.0VCINCLUDExlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
这篇关于如何关闭 MSVC 中的异常处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!