Namespace
Varianti

setjmp

Da cppreference.com.
< cpp‎ | utility‎ | program

 
 
Utilità libreria
Tipo di supporto (basic types, RTTI, type traits)
Gestione della memoria dinamica
La gestione degli errori
Programma di utilità
Funzioni variadic
Data e ora
Funzione oggetti
initializer_list(C++11)
bitset
hash(C++11)
Gli operatori relazionali
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Coppie e tuple
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
Swap, in avanti e spostare
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
Programma di supporto utilità
Programma di terminazione
Original:
Program termination
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
abort
exit
quick_exit(C++11)
_Exit(C++11)
Comunicante con l'ambiente
Original:
Communicating with the environment
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Segnali
Original:
Signals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipi di segnale
Original:
Signal types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
SIGABRT
SIGFPE
SIGILL
SIGINT
SIGSEGV
SIGTERM
Non locali salti
Original:
Non-local jumps
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
setjmp
longjmp
Tipi
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
jmp_buf
 
Elemento definito nell'header <csetjmp>
#define setjmp(env) /* implementation-defined */
Salva il contesto di esecuzione corrente in una variabile di env std::jmp_buf tipo. Questa variabile può essere utilizzata in seguito per ripristinare il contesto di esecuzione corrente per funzione std::longjmp. Cioè, quando una chiamata alla funzione std::longjmp è fatto, l'esecuzione continua al sito di chiamata particolare che la variabile costruito std::jmp_buf passata a std::longjmp. In questo caso restituisce setjmp valore tho passato a std::longjmp.
Original:
Saves the current execution context into a variable env of type std::jmp_buf. This variable can later be used to restore the current execution context by std::longjmp function. That is, when a call to std::longjmp function is made, the execution continues at the particular call site that constructed the std::jmp_buf variable passed to std::longjmp. In that case setjmp returns tho value passed to std::longjmp.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Indice

[modifica] Parametri

env -
variabile per salvare lo stato di esecuzione del programma di .
Original:
variable to save the execution state of the program to.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Valore di ritorno

0 se la macro è stato chiamato dal codice originale e il contesto di esecuzione è stato salvato env.
Original:
0 if the macro was called by the original code and the execution context was saved to env.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Valore diverso da zero se un salto non-locale è stata appena eseguita. Il valore di ritorno, lo stesso che passato a std::longjmp.
Original:
Non-zero value if a non-local jump was just performed. The return value in the same as passed to std::longjmp.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Esempio

#include <iostream>
#include <csetjmp>
 
std::jmp_buf jump_buffer;
 
[[noreturn]] void a(int count) 
{
    std::cout << "a(" << count << ") called\n";
    std::longjmp(jump_buffer, count+1);  // setjump() will return count+1
}
 
int main()
{
    int count = setjmp(jump_buffer);
    if (count != 9) {
        a(count);  // This will cause setjmp() to exit
    }
}

Output:

a(0) called
a(1) called
a(2) called
a(3) called
a(4) called
a(5) called
a(6) called
a(7) called
a(8) called

[modifica] Vedi anche

passa alla posizione specificata
Original:
jumps to specified location
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(funzione) [modifica]
C documentation for setjmp