setjmp/longjmp question
Sir Hoyt
ttwang at polyslo.CalPoly.EDU
Sat Feb 25 04:20:53 AEST 1989
I am considering using setjmp/longjmp to implement exception handling in C.
It would be used like this:
int foo()
{
/* variable allocation here */
if (setjmp( ... ))
{ /* clean up the variables */ }
else
{ /* normal codes */ }
}
Normal codes would including calling other subroutines. When error occurs,
longjmp() will be used to jump back to foo().
I am aware that on the Sun, all register variables cannot be trusted after a
longjmp().
What I want to know is the behavior of setjmp/longjmp on other machines.
Would longjmp() clober all local variables if assuming RISC machine, and
automatic register allocation?
-Thomas Wang ("I am, therefore I am."
- Akira )
ttwang at polyslo.calpoly.edu
More information about the Comp.lang.c
mailing list