tags:

views:

226

answers:

4

Hi I'd like to read good tutorials on setjmp/longjmp in C. It'd be better if there're examples which are real rather than artificial.

Thanks.

A: 

It's not really a tutorial as such, but the libpng documentation describes how the library uses setjmp/longjmp to do error handling.

Greg Hewgill
+1  A: 

Please refer to the example section of this page. The usage of setjmp/longjmp for error handling is described very nicely. Hope this helps you.

vinit dhatrak
A: 

The book "C interfaces and implementation" explains the concept well and implements a usable "exception" simulation in C using these constructs. The code for it (chapter 4) is freely available online here.

Edit: also see this SO thread

Eli Bendersky
A: 

Then you should read Advanced Programming in the UNIX(R) Environment (2nd Edition) Here's the sample you're looking for http://my.safaribooksonline.com/0201433079/ch10lev1sec15 (just a preview)

alinrus