On Wed Nov 10, 1999 at 05:59:40PM -0500, Ju Wang wrote:
> Hi,
>
> Does any body how to use long jump in c/c++, I have a
> program that parse a hierachy structured bitstream, its
> call nested very deep, so I want to get back to the main
> instead of check error in each of the nested function and
> return one by one.
>
>
> Thanks in advance,
> -Ju Wang
Something like this:
#include <stdio.h>
#include <setjmp.h>
jmp_buf errorhandler;
#define FAIL(why) fprintf(stderr, why); longjmp(errorhandler, 1)
void main()
{
/* prepare for error handling */
if (setjmp(errorhandler)) {
exit( 1);
}
/* do stuff */
bar();
exit;
}
void bar()
{
FAIL("I'm long jumping!\n");
}
Now, how does this relate to linux-net?
-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]