Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ames!ncar!gatech!bloom-beacon!oberon!sm.unisys.com!csun!polyslo!ttwang From: ttwang@polyslo.CalPoly.EDU (Sir Hoyt) Newsgroups: comp.lang.c Subject: setjmp/longjmp question Message-ID: <8514@polyslo.CalPoly.EDU> Date: 24 Feb 89 18:20:53 GMT Reply-To: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Distribution: na Organization: Cal Poly State University -- San Luis Obispo Lines: 25 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@polyslo.calpoly.edu