Porting VC++'s __try/__except EXCEPTION_STACK_OVERFLOW to MinGW

前端 未结 4 1925
眼角桃花
眼角桃花 2021-01-02 16:57

I am trying to port some code using VC++\'s try-except statement to MinGW:

bool success = true;

__try {
    //...
} __except ((EXCEPTION_STACK_OVERFLOW == G         


        
4条回答
  •  隐瞒了意图╮
    2021-01-02 17:45

    You would need to manually call the Windows API functions which register exception handling; namely, AddVectoredExceptionHandler. Note that by using MinGW which does not respect SEH exceptions, throwing any SEH exception or attempting to catch any such exception will result in undefined behavior, because the normal C++ stack unwinding semantic isn't done. (How does Windows know to nuke all those std::strings on the stack?)

    You would also need to call RemoveVectoredExceptionHandler at the end of the time you want that SEH exception handler to be called.

    Generally MinGW is lacking in support of Windows features like SEH and COM. Any reason you're trying to use that instead of MSVC++ (given that both compilers are free?)

提交回复
热议问题