Table of contents
1. A rustic mechanism for direct branching in C2. The setjmp macro and the longjmp function
2.1 Prototypes and their roles
2.2 Usage constraints
3. When to use setjmp and longjmp?
4. Practical use of setjmp and longjmp in C
5. Considerations and cautions
6.Multiple jump points
The type that
jmp_buf
corresponds to is always some form of array, although the exact type of its elements is not specified. Wheneversetjmp
andlongjmp
are not in the same function, the memory location used for storing the environment must not be automatic in storage class. It can be either a static variable or a dynamically allocated location.