jmp_buf is an opaque C library-defined object type that represents a saved execution context for setjmp and longjmp. Declare it in a scope that remains active while the jump target is used. section 17.5
A parser jump target
void basic_blocks(void) { jmp_buf jmpTarget; switch (setjmp(jmpTarget)) { case 0: descend(jmpTarget); break; case eofOut: puts("output failed"); break; } } Normal control flow reaches case 0 because setjmp returns zero. A deeper function can call longjmp(jmpTarget, eofOut), transferring control back to the setjmp location, where the nonzero condition selects an alternative case.
Preserve these rules when using a jmp_buf:
- Keep the object alive: leaving the scope of the setjmp call invalidates its jump target. section 17.5
- Keep the saved context active when longjmp is called; a local declaration in the same scope avoids complications. section 17.5
- Treat longjmp as nonreturning: execution does not continue in its caller after the jump. section 17.5

