Help on use of setjmp(), longjmp()

Agostino Deligia agostino at concour.cs.concordia.ca
Fri Apr 26 06:21:21 AEST 1991



Hello,

	Could anyone out there e-mail me an example on how to use setjmp() and
longjmp() to return from a low-level function to an upper-level function?

For example:

void Parse(void) {
  Init();
  DoIt();

  fini:  /* this is where to jump to before quitting Parse() */
  CleanUp();
}

...

void P_E(void) {
  ...
  P_F();
  ...
}

void P_F(void) {
  ...

  if (error)
    /* jump to 'fini' in Parse() */

  ...
}

I read the man pages for setjmp()/longjmp(), but the code fragment they give
doesn't help much.  Also, the only book on C that I have doesn't cover
setjmp()/longjmp().

Any help would be greatly appreciated.  Thank-you.

Agostino Deligia

--
-------------------------------------------------------------------------------
       OO OO     Agostino Deligia
      O O   O    Systems Architecture
     O  O   O    Concordia University, Montreal (Canada)



More information about the Comp.lang.c mailing list