【问题标题】:SEH handler cause compiler warnings and errorsSEH 处理程序导致编译器警告和错误
【发布时间】:2014-01-24 23:23:34
【问题描述】:

我在代码中使用 SEH 处理程序,如下所示:

__try
{
   // code...
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
  TRACE(_T("Exception"));
}

但得到以下编译器错误:

e:\test.cpp(3310): warning C4509: nonstandard extension used: 'CMyClass::Test' uses SEH and 'iterator' has destructor
e:\test.cpp(3290): see declaration of 'iterator'
e:\test.cpp(3450): error C2712: Cannot use __try in functions that require object unwinding

【问题讨论】:

    标签: exception-handling seh


    【解决方案1】:

    这正是错误消息所说的:您不能在需要调用析构函数的函数中使用 SEH。您始终可以将该 __try/__except 块放入子函数中。

    编辑:您可以将该函数设为静态,但在我的测试中,编译器没有内联它,即使使用 __forceinline 也没有。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 2014-03-27
      相关资源
      最近更新 更多