Runtime Library Reference
· Constants
· Data types
Standard C
· assert.h
· complex.h
· ctype.h
· fenv.h
· float.h
· locale.h
· math.h
· setjmp.h
· signal.h
· stdarg.h
· stddef.h
· stdio.h
· stdlib.h
· string.h
· time.h
Standard C++
· IOstream
· new
Win32
· gc.h
DOS, DOS32, Win16
· bios.h
· cerror.h
· disp.h
· dos.h
· dos.h part 2
· emm.h
· handle.h
· int.h
· msmouse.h
· sound.h
· swap.h
· tsr.h
· winio.h
Other C
· bitops.h
· conio.h
· controlc.h
· direct.h
· fltpnt.h
· io.h
· page.h
· process.h
· search.h
· sys\stat.h
· tabsize.h
· trace.h
· utime.h
· unmangle.h
· util.h
Other C++
· regexp.h
· class complex
|
setjmp.h
- Header
- setjmp.h
- Prototype
- void longjmp(jmp_buf env, int value);
- Description
- The longjmp function allows a goto between functions. It is good
for dealing with errors or interrupts encountered in low-level
subroutines of a program. longjmp restores the environment
previously saved by setjmp in a jmp_buf pointed to by envp.
The return value is that of setjmp. The environment must have
been previously saved using setjmp by a function that is currently
active, and which is the same function or a parent of the function
containing the call to longjmp. After completion of longjmp,
program execution continues just as if the corresponding call to
setjmp had just returned with value. The value will never be 0.
If value is passed as 0, the value 1 will be returned.
- Return Value
- None
- Compatibility
- DOS Windows 3.x Phar Lap DOSX Win32
- See Also
- setjmp
- Example
/* Example for longjmp
Also demonstrates setjmp
*/
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
jmp_buf environment;
int error_val = -1;
void docall(void)
{
longjmp(environment, error_val);
}
void main()
{
int error_code;
error_code = setjmp(environment);
if (error_code != 0)
{
printf ("Longjmp called\n");
exit (EXIT_FAILURE);
}
printf("Setjmp called\n");
docall();
}
- Output
Setjmp called
Longjmp called
- Header
- setjmp.h
- Prototype
- int setjmp(jmp_buf env);
- Description
- Coupled with longjmp, setjmp allows a "goto" between functions.
Jumps are good for dealing with errors or interrupts encountered in
low-level subroutines of a program.
- Synonym
- Function: _setjmp
- Return Value
- setjmp returns a 0 when it is called to save the environment for a
subsequent longjmp call; its value is that of the longjmp
argument. If the longjmp argument is 0, it is changed to 1.
- Compatibility
- DOS Windows 3.x Phar Lap DOSX Win32
- See Also
- longjmp
|