0

I use a SEH handler in my code, like this:

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

but get the following compiler errors:

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
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
alancc
  • 487
  • 2
  • 24
  • 68

1 Answers1

1

It's just what the error message says: you can not use SEH in functions that require destructors to be called. You can always put that __try/__except block into a sub-function.

Edit: You can make that function static, but in my tests the compiler didn't inline it, not even with __forceinline.

cxxl
  • 4,939
  • 3
  • 31
  • 52