setjmp/longjump
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at setjmp-longjump.
When you include setjmpex.h or setjmp.h, all calls to setjmp or longjmp will result in an unwind that invokes destructors and finally calls. This differs from x86, where including setjmp.h results in finally clauses and destructors not being invoked.
A call to setjmp
preserves the current stack pointer, non-volatile registers, and MxCsr registers. Calls to longjmp
return to the most recent setjmp
call site and resets the stack pointer, non-volatile registers, and MxCsr registers, back to the state as preserved by the most recent setjmp
call.