I am having problems with help error C2712: Cannot use __try in functions that require object unwinding, after narrowing the problem I still have very simple code, and I can’t understand why it is causing this error. I am using Visual Studio under windows.
I compile with / EHa (I do not use / EHsc)
The reason I use __try/__except, and not try/catch, is that I want to catch ALL errors and do not want the program to crash under any circumstances, including, for example, dividing by 0, this try-catch is not a catch.
#include <string>
static struct myStruct
{
static std::string foo() {return "abc";}
};
int main ()
{
myStruct::foo();
__try
{ }
__except (true)
{ }
return 0;
}
output:
error C2712: Cannot use __try in functions that require object unwinding
source
share