如何关闭MSVC中的异常处理? [英] How can I switch off exception handling in MSVC?

查看:370
本文介绍了如何关闭MSVC中的异常处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何关闭MSVC中的异常处理选项?我试图将选项'启用C ++异常'设置为'否',并且我收到警告:
警告C4530:使用C ++异常处理程序,但展开语义未启用。指定/ EHsc



我也想关闭异常处理程序,但我不知道如何。



在我的应用程序中,我基本上需要更多的稳定性,因此我选择关闭异常处理。我没有任何try / catch块,但我使用STL。当我将选项'启用C ++异常'切换到'否'时,有没有办法摆脱这些警告?

解决方案

< iostream> - 您将在一个文件中收到这个错误,该文件只包含一行。任何其他流标题也将与locales一样。



如果仔细观察错误消息,它应该引用两个文件名,而不是一个文件,而且包含错误的文件。例如。在我的 #include< iostream> 的示例案例中,我得到:

  except.cpp 
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342):警告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.

In my application I basically need more speer 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?

解决方案

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.

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 Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc

这篇关于如何关闭MSVC中的异常处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆