c语言的跳转longjmp

#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:跳转标记)

你可能感兴趣的:(C语言,跳转longjmp)