#include <csetjmp>
#include <cstdlib>
static jmp_buf g_env;
void Recursion (int nDepth) {
if (nDepth >= 3)
longjmp (g_env, 1);
Recursion (nDepth + 1);
}
int main (int argc, char* argv[]) {
int nRetVal = setjmp (g_env);
if (nRetVal == 1)
{
return 0;
}
Recursion (0);
return 0;
}
運行流程:
main --> setjmp --(x:跳轉標記)--> if( == 1) --> Recursion() --> longjmp() --> (x:跳轉標記)