您的位置:首页 > 其它

Visual Studio 中使用try except 遇到的问题

2015-07-09 16:45 148 查看
在Visual Studio 中使用try except , compile的时候遇到如下error:


__try in functions containing objects with destructors

原因是在使用try/except 的时候,不可以在函数中有object unwinding and destruction.

解决办法, 参考微软: Compiler Error C2712

Move code that requires SEH to another function

Rewrite functions that use SEH to avoid the use of local variables and parameters that have destructors. Do not use SEH in constructors or destructors

Compile without /EHsc

我在项目中的解决方法是采用的第三种:

打开项目的property, C/C++ –> Enable C++ Exceptions , 改为No.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  visual studio