Example 3. Volatile for Local Variables With setjmp

#include <stdlib.h> jmp_buf context; void function() { volatile int x = 3; switch(setjmp(context)) { case 0: setup(); break; default: { /* We only reach here if longjmp occurs. Because x's lifetime begins before setjmp and lasts through longjmp, the C standard requires x be declared "volatile". */ printf("x == %d\n", x); break; } } }