Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

setjmp - Set label for non-local jumps

&pagelevel(4)&pagelevel

Definition

#include <setjmp.h>

int setjmp(jmp_buf env);

setjmp is only meaningful when used in conjunction with the longjmp function. These
functions can be used to implement non-local jumps, i.e. a jump from any given function to
another, still active function.

setjmp stores the current program state (address in the C runtime stack, program counter,
register contents) in a field of type jmp_buf. The type jmp_buf is defined in <setjmp.h>.
A subsequent longjmp call re-establishes the program state stored by setjmp and
continues program execution from this state.

A detailed description and notes on setjmp/longjmp are provided under the longjmp
function.

Return val.

0

normal return, i.e. a longjmp call was not used to branch to the position
after the setjmp call.

!= 0

if longjmp was used to branch to the position after the setjmp call. This
return value is the argument value of the longjmp call (if value is equal to 0,
setjmp returns 1).

Example

See also

See example under longjmp

longjmp, signal