Share via


setjmp (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Reference

Saves the current state of the program.

int setjmp( 
jmp_bufenv);

Parameters

  • env
    Variable in which environment is stored.

Return Values

setjmp returns 0 after saving the stack environment. If setjmp returns as a result of a longjmp call, it returns the value argument of longjmp, or if the value argument of longjmp is 0, setjmp returns 1. There is no error return.

Remarks

These functions are supported by all versions of the C run-time libraries.

The setjmp function saves a stack environment, which you can subsequently restore using longjmp. When used together, setjmp and longjmp provide a way to execute a non-local goto. They are typically used to pass execution control to error-handling or recovery code in a previously called routine without using the normal calling or return conventions.

A call to setjmp saves the current stack environment in env. A subsequent call to longjmp restores the saved environment and returns control to the point just after the corresponding setjmp call. All variables (except register variables) accessible to the routine receiving control contain the values they had when longjmp was called.

setjmp and longjmp do not support C++ object semantics. In C++ programs, use the C++ exception-handling mechanism. Using the longjmp or setjmp run-time routines in a C++ program will generate a link error if C++ exceptions are enabled using the /GX-Enable Exception Handling compiler option.

Requirements

OS Versions: Windows CE 2.0 and later.

Header: stdlib.h.

Link Library: coredll.dll.

See Also

longjmp | _fpreset

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.