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 longjmp() 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.
PrototypeDescription
int setjump(jmp_buf env);Saves the calling environment in the array env and returns 0 if called directly, non-zero if the return is from a call to longjmp() ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.