Behaviour of setjmp/longjmp and registers

Gordon Cross crossgl at ingr.com
Tue Jan 24 05:17:42 AEST 1989


In article <9480 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>
>I don't think I've even seen a case in which setjmp/longjmp was the best
>way to design code, let alone essential.

I tend to disagree with this.  I do avoid the use of setjmp/longjmp where they
are not needed but try to correctly handle error recovery in a large
interactive program without them!  I have developed a caller-configurable
error processor that takes care of such monsters nicely:  an error is reported,
handled, and recovered from simply by using something like

     if (read (descriptor, buffer, sizeof (buffer)) == -1)
       report_error (READFAIL, ERR_FATAL);

     do_normal_stuff ();   /* report_error does NOT return on FATAL!! */
-- 

Gordon Cross             UUCP:      uunet!ingr!crossgl     "all opinions are
111 Westminister Way     INTERNET:  crossgl at ingr.com        mine and not those
Madison, AL 35758        MA BELL:   (205) 772-7842          of my employer."



More information about the Comp.lang.c mailing list