GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::jmp_buf(3) C++ Standard Libary std::jmp_buf(3)

std::jmp_buf - std::jmp_buf


Defined in header <csetjmp>
typedef /* unspecified */ jmp_buf;


The std::jmp_buf type is an array type suitable for storing information to restore a
calling environment. The stored information is sufficient to restore execution at
the correct block of the program and invocation of that block. The state of
floating-point status flags, or open files, or any other data is not stored in an
object of type jmp_buf.

// Run this code


#include <iostream>
#include <csetjmp>


std::jmp_buf my_jump_buffer;


[[noreturn]] void foo(int count)
{
std::cout << "foo(" << count << ") called\n";
std::longjmp(my_jump_buffer, count+1); // setjmp() will return count+1
}


int main()
{
volatile int count = 0; // modified locals in setjmp scope must be volatile
if (setjmp(my_jump_buffer) != 5) { // equality against constant expression in an if
count = count + 1; // ++count, count += 1, etc on 'volatile'-qualified
// left operand are deprecated since C++20 (P1152)
foo(count); // This will cause setjmp() to exit
}
}


foo(1) called
foo(2) called
foo(3) called
foo(4) called


setjmp saves the context
(function macro)
longjmp jumps to specified location
(function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.