Non-Local Jumps: setjmp.h

I l @ ve RuBoard

Non-Local Jumps: setjmp.h

The setjmp.h header file enables you to bypass the usual function call, function return sequence. The setjmp() function stores information about the current execution environment, for example, a pointer to the current instruction, in a type jmp_buf variable (an array type defined in this header file), and the l ongjmp() function transfers execution to such an environment. The functions are intended to help handle error conditions, not to be used as part of normal program flow control. Table F.7 lists the functions.

Table  F.7. Localization functions.
Prototype Description
int setjump(jmp_buf env); Saves the calling environment in the array env and returns if called directly, non-zero if the return is from a call to longjmp() .
void longjmp(jmp_buf env, int val); Restores the environment saved by the most recent evocation of setjmp() that set the env array; after completing this change, the program continues as though that evocation of setjmp() had returned val , except that a return value of is not allowed and is converted to 1 .
I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net