# <setjmp.h> <setjmp.h> # `` * * * Include the standard header **``** to perform control transfers that bypass the normal function call and return protocol. #define setjmp(jmp_buf env) typedef a-type jmp_buf; void longjmp(jmp_buf env, int val);Copy to clipboard ## `jmp_buf` typedef a-type jmp_buf;Copy to clipboard The type is the array type `a-type` of an object that you declare to hold the context information stored by [`setjmp`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_setjmp.html#setjmp) and accessed by [`longjmp`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_setjmp.html#longjmp). ## `longjmp` void longjmp(jmp_buf env, int val);Copy to clipboard The function causes a second return from the execution of [`setjmp`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_setjmp.html#setjmp) that stored the current context value in `env`. If `val` is nonzero, the return value is `val`; otherwise, it is 1. The function that was active when [`setjmp`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_setjmp.html#setjmp) stored the current context value must not have returned control to its caller. An object with dynamic duration that does not have a *volatile* type and whose stored value has changed since the current context value was stored will have a stored value that is indeterminate. ## `setjmp` #define setjmp(jmp_buf env) Copy to clipboard The macro stores the current context value in the array designated by `env` and returns zero. A later call to [`longjmp`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_setjmp.html#longjmp) that accesses the same context value causes `setjmp` to again return, this time with a nonzero value. You can use the macro `setjmp` only in an expression that: - has no operators - has only the unary operator `!` - has one of the relational or equality operators (`==`, `!=`, `<`, `<=`, `>`, or `>=`) with the other operand an integer constant expression You can write such an expression only as the *expression* part of a [*do*](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_function.html#Do%20Statement), [*expression*](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_function.html#Expression%20Statement), [*for*](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_function.html#For%20Statement), [*if*](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_function.html#If%20Statement), [*if-else*](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_function.html#If-Else%20Statement), [*switch,*](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_function.html#Switch%20Statement), or [*while*](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_function.html#While%20Statement) statement. * * * See also the **[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#Table%20of%20Contents)** and the **[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_cpp_index.html)**. *[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_pjp.html) © 1992-2006by P.J. Plauger and Jim Brodie. All rights reserved.* Last Published: Oct 06, 2026 Previous Topic Next Topic