==Nested catch blocks== 
 I'm putting this example here rather than in the article because it's so horribly hackish. Most importantly, I realized after writing the above comment that there's no way to "re-throw" an arbitrary status from first back to main; the nested function has to "declare" each of the exception types it might re-throw, which I've done with the RETHROW(value) macro. N.B.: the memcpy calls are virtually guaranteed to do the right thing, because jmp_buf is "an array type suitable for holding the information needed to restore a calling environment". (Still, that doesn't mean it does hold all the information needed to restore the environment — it could be an array[1] of pointers to records that really hold the data. But that would just be evil.) 
 :If anyone can come up with a library (not original research ) that uses setjmp this way, I think that would be a valuable addition to the article.   

  #include  
  #include  
  #include  
 
  static jmp_buf global_jmpbuf; 
 
   
  #define THROW(value)    longjmp(global_jmpbuf, value) 
  #define TRY             do { jmp_buf tmp; \ 
                          memcpy(tmp, global_jmpbuf, sizeof tmp); \ 
                          switch (setjmp(global_jmpbuf)) { case 0: 
  #define CATCH(value)    break; case value: 
  #define RETHROW(value)  break; case value: \ 
                          memcpy(global_jmpbuf, tmp, sizeof tmp); \ 
                          THROW(value); 
  #define ENDTRY          break; } \ 
                          memcpy(global_jmpbuf, tmp, sizeof tmp); } while (0) 
 
  void first(void); 
  void second(void); 
 
  int main() 
  { 
      TRY { 
          first(); 
          puts("Returned to main."); 
      } CATCH(1) { 
          puts("Caught 1 in main"); 
      } ENDTRY; 
      return 0; 
  } 
 
  void first(void) 
  { 
      TRY { 
          second(); 
      } CATCH(2) { 
          puts("Caught 2 in first"); 
      } RETHROW(1) ENDTRY; 
      return; 
  } 
 
  void second(void) 
  { 
      THROW(1); 
   /* THROW(2); */ 
  }