Latest web development tutorials

C standard library - <setjmp.h>

Brief introduction

setjmp.h header file defines macros setjmp (),the functionlongjmp ()and variable typejmp_buf,the variable type will bypass the normal function call and return rules.

Library variants

The following lists the variables defined in the header file setjmp.h:

序号变量 & 描述
1jmp_buf
这是一个用于存储宏setjmp()和函数longjmp()相关信息的数组类型。

Macro library

The following is only a macro defined in the library:

序号宏 & 描述
1 int setjmp(jmp_buf environment)
这个宏把当前环境保存在变量environment中,以便函数longjmp()后续使用。如果这个宏直接从宏调用中返回,则它会返回零,但是如果它从longjmp()函数调用中返回,则它会返回一个非零值。

Library Functions

The following is only a function defined in the header file setjmp.h:

序号函数 & 描述
1 void longjmp(jmp_buf environment, int value)
该函数恢复最近一次调用setjmp()宏时保存的环境,jmp_buf参数的设置是由之前调用 setjmp() 生成的。