User Tools

Site Tools


c:setjmp.h:longjmp
click
to support this page (eg 0,42 € or so) Thanks.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:setjmp.h:longjmp [2013/02/03 19:14]
127.0.0.1 external edit
c:setjmp.h:longjmp [2013/02/04 19:40] (current)
158.181.88.241
Line 1: Line 1:
 ====== longjmp ====== ====== longjmp ======
 <code c> <code c>
 +void longjmp (jmp_buf env, int val);
 </code> </code>
  
 ==== description of longjmp ==== ==== description of longjmp ====
-longjmp is in work by code-reference.com \\  +get program state from the stack, useful for debugging.
-if you are faster... don't hasitate and add it+
  
 <code c> <code c>
-no example at the moment+#include <stdio.h> 
 +#include <setjmp.h> 
 + 
 +void testit(int); 
 +jmp_buf program_state; 
 + 
 +static int count; 
 +void testit(int count) { 
 + 
 +   count++; // set counter +1 but it will never reach 2 
 +   printf("count is now %i\n", count); 
 +   } 
 + 
 +int main(void) { 
 +   count = 0; 
 +   printf("count starts with: %i\n", count); 
 + 
 +   if(setjmp(program_state) == 0) { 
 +       printf("save program state in the stack\n"); 
 +       testit(count); 
 +   } 
 +   else { 
 +        printf("callback with longjmp\n"); 
 +        testit(count); 
 +        testit(count); 
 +        return 0; 
 +   } 
 + 
 +   testit(count); 
 +   longjmp(program_state,1); 
 +   printf("never called\n"); 
 +   testit(count); 
 + 
 +   return 0; 
 +
 </code> </code>
  
 ===== output of longjmp c example ===== ===== output of longjmp c example =====
-    no example at the moment +    count starts with: 0 
 +    save program state in the stack 
 +    count is now 1 
 +    count is now 1 
 +    callback with longjmp 
 +    count is now 1 
 +    count is now 1 
 +    
advertising
c/setjmp.h/longjmp.txt · Last modified: 2013/02/04 19:40 by 158.181.88.241

Impressum