[Previous] [Contents] [Next]

<setjmp.h>


Include the standard header <setjmp.h> to perform control transfers that bypass the normal function call and return protocol.

#define setjmp(jmp_buf env) <int rvalue>

typedef a-type jmp_buf;
void longjmp(jmp_buf env, int val);

jmp_buf

typedef a-type jmp_buf;

The type is the array type a-type of an object that you declare to hold the context information stored by setjmp and accessed by longjmp.

longjmp

void longjmp(jmp_buf env, int val);

The function causes a second return from the execution of setjmp that stored the current context value in env. If val is nonzero, the return value is val; otherwise, it is 1.

The function that was active when setjmp stored the current context value must not have returned control to its caller. An object with dynamic duration that does not have a volatile type and whose stored value has changed since the current context value was stored will have a stored value that is indeterminate.

setjmp

#define setjmp(jmp_buf env) <int rvalue>

The macro stores the current context value in the array designated by env and returns zero. A later call to longjmp that accesses the same context value causes setjmp to again return, this time with a nonzero value. You can use the macro setjmp only in an expression that:

You can write such an expression only as the expression part of a do, expression, for, if, if-else, switch,, or while statement.


See also the Table of Contents and the Index.

Copyright © 1989-2002 by P.J. Plauger and Jim Brodie. All rights reserved.

[Previous] [Contents] [Next]