While the C language has the dreaded goto statement, it
can only be used to jump to a label in the same (local) function. In order to jump directly
to another (non-local) function, the C library provides the setjmp()
and longjmp() functions. setjmp() and longjmp()
are useful for dealing with errors and interrupts encountered in a low-level subroutine of a
program.
setjmp() and longjmp() make programs hard to understand and maintain. If possible, an alternative should be used.
longjmp() can destroy changes made to global register variables (see How to permanently bind a variable to a register?).
Example: