📄 setjmp.html
字号:
<HTML><HEAD><TITLE><setjmp.h></TITLE></HEAD><BODY><H1><A NAME="<setjmp.h>"><CODE><setjmp.h></CODE></A></H1><HR><P>Include the standard header <B><CODE><setjmp.h></CODE></B>to perform control transfers that bypassthe normal function call and return protocol.</P><PRE>#define <A HREF="#setjmp"><B>setjmp</B></A>(jmp_buf env) <I><int rvalue></I>typedef <I>a-type</I> <A HREF="#jmp_buf"><B>jmp_buf</B></A>;void <A HREF="#longjmp"><B>longjmp</B></A>(jmp_buf env, int val);</PRE><H2><A NAME="jmp_buf"><CODE>jmp_buf</CODE></A></H2><PRE>typedef <I>a-type</I> <B>jmp_buf</B>;</PRE><P>The type is the array type <CODE><I>a-type</I></CODE> of an object thatyou declare to hold the context information stored by<A HREF="#setjmp"><CODE>setjmp</CODE></A> and accessed by<A HREF="#longjmp"><CODE>longjmp</CODE></A>.</P><H2><A NAME="longjmp"><CODE>longjmp</CODE></A></H2><PRE>void <B>longjmp</B>(jmp_buf env, int val);</PRE><P>The function causes a second return from the execution of<A HREF="#setjmp"><CODE>setjmp</CODE></A>that stored the current context value in <CODE>env</CODE>.If <CODE>val</CODE> is nonzero, the return value is <CODE>val</CODE>;otherwise, it is 1.</P><P>The function that was active when<A HREF="#setjmp"><CODE>setjmp</CODE></A> stored the currentcontext value must not have returned control to its caller. An objectwith dynamic duration that does not have a <I>volatile</I> type andwhose stored value has changed since the current context value was storedwill have a stored value that is indeterminate.</P><H2><A NAME="setjmp"><CODE>setjmp</CODE></A></H2><PRE>#define <B>setjmp</B>(jmp_buf env) <I><int rvalue></I></PRE><P>The macro stores the current context value in the arraydesignated by <CODE>env</CODE> and returns zero. A later call to<A HREF="#longjmp"><CODE>longjmp</CODE></A>that accesses the same context value causes<CODE>setjmp</CODE> to again return, this time with a nonzero value.You can use the macro <CODE>setjmp</CODE> only in an expression that:</P><UL><LI>has no operators<LI>has only the unary operator <CODE>!</CODE><LI>has one of the relational or equality operators (<CODE>==</CODE>,<CODE>!=</CODE>, <CODE><</CODE>, <CODE><=</CODE>,<CODE>></CODE>, or <CODE>>=</CODE>) with the otheroperand an integer constant expression</UL><P>You can write such an expression only as the <I>expression</I>part of a<A HREF="function.html#Do Statement"><I>do</I></A>,<A HREF="function.html#Expression Statement"><I>expression</I></A>,<A HREF="function.html#For Statement"><I>for</I></A>,<A HREF="function.html#If Statement"><I>if</I></A>,<A HREF="function.html#If-Else Statement"><I>if-else</I></A>,<A HREF="function.html#Switch Statement"><I>switch,</I></A>, or<A HREF="function.html#While Statement"><I>while</I></A> statement.</P><HR><P>See also the<B><A HREF="index.html#Table of Contents">Table of Contents</A></B> and the<B><A HREF="_index.html">Index</A></B>.</P><P><I><A HREF="crit_pb.html">Copyright</A> © 1989-2002by P.J. Plauger and Jim Brodie. All rights reserved.</I></P><!--V4.01:1125--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -