std::longjmp
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Déclaré dans l'en-tête <csetjmp>
|
||
void longjmp( std::jmp_buf env, int status ); |
||
Charge le contexte d'exécution
env sauvé par un précédent appel à setjmp. Cette fonction ne retourne pas. Le contrôle est transféré sur le site de l'appel setjmp macro mis en place env. C'est setjmp retourne alors la valeur, passée comme status .Original:
Loads the execution context
env saved by a previous call to setjmp. This function does not return. Control is transferred to the call site of the macro setjmp that set up env. That setjmp then returns the value, passed as the status.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.
Si la fonction qui a appelé setjmp a quitté, le comportement est indéfini (en d'autres termes, seuls les sauts en longueur jusqu'à la pile d'appels sont autorisés)
Original:
If the function that called setjmp has exited, the behavior is undefined (in other words, only long jumps up the call stack are allowed)
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.
Pas destructeurs pour les objets automatiques sont appelés. En cas de remplacement de
std::longjmp avec throw et setjmp avec catch exécuterait un destructeur non trivial pour tout objet automatique, le comportement des std::longjmp telle n'est pas définie .Original:
No destructors for automatic objects are called. If replacing of
std::longjmp with throw and setjmp with catch would execute a non-trivial destructor for any automatic object, the behavior of such std::longjmp is undefined.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.
Paramètres
| env | - | variable de référence à l'état d'exécution du programme enregistré par
std::setjmpOriginal: variable referring to the execution state of the program saved by std::setjmpThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| status | - | la valeur de retour de setjmp. Si elle est égale à
0, 1 est utilisé à la placeOriginal: the value to return from setjmp. If it is equal to 0, 1 is used insteadThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Retourne la valeur
(Aucun)
Original:
(none)
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.
Exemple
#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
}
}
Résultat :
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
Voir aussi
sauvegarde le contexte Original: saves the context The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction macro) | |
C documentation for longjmp
| |