A
Anders Koeln
Hi
I'm having a problem with setjump()/longjump(). The actual calls
are disguised inside two routines which attempt to implement an
exception handling mechanism.
The first routine, try() calls setjmp(). The throw() routine
calls longjmp(). According to my man page, setjmp() returns 0
when it is really called and 1 when it got there via longjump().
I test for a 1 return and jump to the exception handler.
Except that's not what's happening. Inside the try() routine,
I can see setjmp() being called, and returning 0. Then, my
main code calls throw(), and I see setjump() returning 1. Instead
of returning to the point where try() was called, however, it
returns to the point after which throw() was called, as if
throw() had returned normally without doing a longjmp().
|
try <-.
| |
V |
throw |
|____|
That's what I expect to happen.
|
.- try <-.
| | |
| V |
| throw |
| |____|
|___.
|
V
That's what's actually happening.
Thanks in advance for any help.
I'm having a problem with setjump()/longjump(). The actual calls
are disguised inside two routines which attempt to implement an
exception handling mechanism.
The first routine, try() calls setjmp(). The throw() routine
calls longjmp(). According to my man page, setjmp() returns 0
when it is really called and 1 when it got there via longjump().
I test for a 1 return and jump to the exception handler.
Except that's not what's happening. Inside the try() routine,
I can see setjmp() being called, and returning 0. Then, my
main code calls throw(), and I see setjump() returning 1. Instead
of returning to the point where try() was called, however, it
returns to the point after which throw() was called, as if
throw() had returned normally without doing a longjmp().
|
try <-.
| |
V |
throw |
|____|
That's what I expect to happen.
|
.- try <-.
| | |
| V |
| throw |
| |____|
|___.
|
V
That's what's actually happening.
Thanks in advance for any help.