版本1和2间的区别
于2006-06-20 20:37:37修订的的版本1
大小: 1271
编辑: czk
备注:
于2007-07-18 21:03:43修订的的版本2
大小: 1347
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 1: 行号 1:
## page was renamed from Standard Library/B.08 Non-local Jumps: <setjmp.h>

Navigation(slides)

B.8 Non-local Jumps: <setjmp.h>

The declarations in <setjmp.h> provide a way to avoid the normal function call and return sequence, typically to permit an immediate return from a deeply nested function call.

int setjmp(jmp_buf env)

  • The macro setjmp saves state information in env for use by longjmp. The return is zero from a direct call of setjmp, and non-zero from a subsequent call of longjmp. A call to setjmp can only occur in certain contexts, basically the test of if, switch, and loops, and only in simple relational expressions.

      if (setjmp(env) == 0)
          /* get here on direct call */
      else
          /* get here by calling longjmp */

void longjmp(jmp_buf env, int val)

  • longjmp restores the state saved by the most recent call to setjmp, using the information saved in env, and execution resumes as if the setjmp function had just executed and returned the non-zero value val. The function containing the setjmp must not have terminated. Accessible objects have the values they had at the time longjmp was called, except that non-volatile automatic variables in the function calling setjmp become undefined if they were changed after the setjmp call.

Navigation(siblings)

TCPL/B.08_Non-local_Jumps:_<setjmp.h> (2008-02-23 15:37:08由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.