setjmp
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
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.
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.
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.
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) | |
C documentation for setjmp
|