function
longjmp
<setjmp>
void longjmp (jmp_buf env, int val);
Long jump
Restores the environment by the most recent invocation of the
setjmp macro in the same invocation of the program. The information required to restore this environment is provided by parameter
env, whose value is obtained from a previous call to
setjmp.
The function never returns to the point where it has been invoked. Instead, the function transfers the control to the point where
setjmp was used to fill the
env parameter.
Parameters
- env
- Object of type jmp_buf containing information to restore the environment at the setjmp's calling point.
- val
- Value to which the setjmp expression evaluates.
Return value
None. The function never returns.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
/* longjmp example */
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
main()
{
jmp_buf env;
int val;
val=setjmp(env);
printf ("val is %d\n",val);
if (!val) longjmp(env, 1);
return 0;
}
|
Output:
See also
- setjmp
- Save calling environment for long jump (macro)
- jmp_buf
- Type to hold information to restore calling environment (type)