Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/utility/program/longjmp"

From cppreference.com
< cpp‎ | utility‎ | program
m (+example etc)
(+explicit restrictions)
Line 5: Line 5:
 
}}
 
}}
  
Loads the execution context {{tt|env}} saved by a previous call to {{cpp|setjmp}}. This function does not return. Control is transferred to the particular call site of {{cpp|setjmp}} that set up {{tt|env}}. That {{cpp|setjmp}} then returns the value, passed as the {{tt|status}}.
+
Loads the execution context {{tt|env}} saved by a previous call to {{cpp|setjmp}}. This function does not return. Control is transferred to the call site of the macro {{cpp|setjmp}} that set up {{tt|env}}. That {{cpp|setjmp}} then returns the value, passed as the {{tt|status}}.
  
No cleanup such as calling destructors is done during transfer of control.  
+
If the function that called {{cpp|setjmp}} has exited, the behavior is undefined (in other words, only long jumps up the call stack are allowed)
 +
 
 +
No destructors for automatic objects are called. If replacing of {{tt|std::longjmp}} with {{cpp|throw}} and {{cpp|setjmp}} with {{cpp|catch}} would execute a non-trivial destructor for any automatic object, the behavior of such {{cpp|std::longjmp}} is undefined.
  
 
===Parameters===
 
===Parameters===

Revision as of 12:16, 8 November 2011

Template:cpp/utility/program/sidebar

Defined in header <csetjmp>
void longjmp( std::jmp_buf env, int status );

Loads the execution context env saved by a previous call to Template:cpp. This function does not return. Control is transferred to the call site of the macro Template:cpp that set up env. That Template:cpp then returns the value, passed as the status.

If the function that called Template:cpp has exited, the behavior is undefined (in other words, only long jumps up the call stack are allowed)

No destructors for automatic objects are called. If replacing of std::longjmp with Template:cpp and Template:cpp with Template:cpp would execute a non-trivial destructor for any automatic object, the behavior of such Template:cpp is undefined.

Contents

Parameters

env - variable referring to the execution state of the program saved by Template:cpp
status - the value to return from Template:cpp. If it is equal to Template:cpp, Template:cpp is used instead

Return value

(none)

Example

Template:example cpp

See also

saves the context
(function macro) [edit]