Espacios de nombres
Variantes
Acciones

setjmp

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

 
 
Utilidades de la biblioteca
Escriba apoyo (basic types, RTTI, type traits)
Gestión de memoria dinámica
Gestión de errores
Programa de servicios públicos
Funciones variadic
Fecha y hora
Objetos Function
initializer_list(C++11)
bitset
hash(C++11)
Operadores relacionales
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>=
Pares y tuplas
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)
Cambiar, hacia adelante y mover
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)
 
Servicios públicos de apoyo a programas
Programa terminación
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)
La comunicación con el medio 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.
Señales
Original:
Signals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos de señal
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
No locales saltos
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
Tipos
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
 
Defined in header <csetjmp>
#define setjmp(env) /* implementation-defined */
Guarda el contexto de ejecución actual en una variable de env std::jmp_buf tipo. Esta variable puede utilizarse posteriormente para restaurar el contexto de ejecución actual en función std::longjmp. Esto es, cuando una llamada a función std::longjmp está hecho, la ejecución continúa en el sitio de llamada particular, que construye la variable std::jmp_buf pasa a std::longjmp. En ese caso vuelve setjmp valor aunque pasó 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.

Contenido

[editar] Parámetros

env -
variable para guardar el estado de ejecución del programa para .
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.

[editar] Valor de retorno

0 si la macro fue llamado por el código original y el contexto de ejecución se guardó en 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.
Valor distinto de cero si el salto no local se acaba de realizar. El valor de retorno de la misma pasa 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.

[editar] Ejemplo

#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

[editar] Ver también

salta a la ubicación especificada
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.

(función) [edit]
C documentation for setjmp