Saves the current state of the program.
#include <setjmp.h>
int setjmp( jmp_buf env );
env | Variable in which environment is stored |
The setjmp function saves a stack environment that can be subsequently restored using longjmp. Used together this way, setjmp and longjmp provide a way to execute a “non-local goto.” They are typically used to pass execution control to error-handling or recovery code in a previously called routine without using the normal calling or return conventions.
A call to setjmp causes the current stack environment to be saved in env. A subsequent call to longjmp restores the saved environment and returns control to the point just after the corresponding setjmp call. All variables (except register variables) accessible to the routine receiving control contain the values they had when setjmp was called.
Warning!:
Neither the setjmp nor the longjmp function is compatible with the C++ language.
The setjmp function returns 0 after saving the stack environment. If setjmp returns as a result of a longjmp call, it returns the value argument of longjmp, or if the value argument of longjmp is 0, setjmp returns 1. There is no error return.
Standards:ANSI, UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
See the example for _fpreset.