On Fri Nov 12, 1999 at 11:38:12AM +0100, Glynn Clements wrote:
> 
> >     #include <setjmp.h>
> > 
> >     jmp_buf errorhandler;
> >     #define FAIL(why)       fprintf(stderr, why); longjmp(errorhandler, 1)
> 
> Ouch. If someone decides to write:
> 
>       if (...)
>         FAIL(...);
> 
> the result won't be what they expect, and the bug could be fairly hard
> to find. The usual solution is to use something like:
> 
> #define FAIL(why)  do {fprintf(stderr, why); longjmp(errorhandler, 1);} while (0)
> 
> which is a single statement, and so doesn't have this problem.

Good point.  I was overly terse.

 -Erik

--
Erik B. Andersen   Web:    http://www.xmission.com/~andersen/ 
                   email:  [EMAIL PROTECTED]
--This message was written using 73% post-consumer electrons--
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to