⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stdarg.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
字号:
<HTML><HEAD><TITLE>&lt;stdarg.h&gt;</TITLE></HEAD><BODY><H1><A NAME="&lt;stdarg.h&gt;"><CODE>&lt;stdarg.h&gt;</CODE></A></H1><HR><P>Include the standard header <B><CODE>&lt;stdarg.h&gt;</CODE></B>to access the unnamed additional arguments(arguments with no corresponding parameter declarations)in a function that accepts a<B><A NAME="varying number of arguments">varying numberof arguments</A></B>. To access the additional arguments:</P><UL><LI>The program must first execute the macro<A HREF="#va_start"><CODE>va_start</CODE></A> withinthe body of the function to initialize an object with context information.<LI>Subsequent execution of the macro<A HREF="#va_arg"><CODE>va_arg</CODE></A>, designatingthe same context information, yields the values of the additionalarguments in order, beginning with the first unnamed argument. Youcan execute the macro<A HREF="#va_arg"><CODE>va_arg</CODE></A>from any function that can accessthe context information saved by the macro<A HREF="#va_start"><CODE>va_start</CODE></A>.<LI>If you have executed the macro<A HREF="#va_start"><CODE>va_start</CODE></A>in a function, you must execute the macro<A HREF="#va_end"><CODE>va_end</CODE></A>in the same function, designatingthe same context information, before the function returns.</UL><P>You can repeat this sequence (as needed) to access the argumentsas often as you want.</P><P>You declare an object of type<A HREF="#va_list"><CODE>va_list</CODE></A>to store context information.<A HREF="#va_list"><CODE>va_list</CODE></A>can be either an array type or a non-array type.Whether or not <CODE>va_list</CODE> is an array type affects howthe program shares context information with functions that it calls.The address of the first element of an array is passed, rather thanthe object itself. So an array type is effectively passed by reference, whilea non-array type is passed by value.</P><P>For example:</P><PRE>#include &lt;stdarg.h&gt;void va_cat(char *s, ...)    {    char *t;    va_list ap;    va_start(ap, s);    while (t = va_arg(ap, char *)) <B>null pointer ends list</B>        {        s += strlen(s);            <B>skip to end</B>        strcpy(s, t);              <B>and copy a string</B>        }    va_end(ap);    }</PRE><P>The function <CODE>va_cat</CODE>concatenates an arbitrary number of strings onto the end of anexisting string (assuming that the existing string is stored in anobject large enough to hold the resulting string).</P><PRE>#define <A HREF="#va_arg"><B>va_arg</B></A>(va_list ap, <I>Ty</I>) <I>&lt;rvalue of type Ty&gt;</I>#define <A HREF="#va_end"><B>va_end</B></A>(va_list ap) <I>&lt;void expression&gt;</I>#define <A HREF="#va_start"><B>va_start</B></A>(va_list ap, <I>last-par</I>) <I>&lt;void expression&gt;</I>typedef <I>do-type</I> <A HREF="#va_list"><B>va_list</B></A>;</PRE><H2><A NAME="va_arg"><CODE>va_arg</CODE></A></H2><PRE>#define <B>va_arg</B>(va_list ap, <I>Ty</I>) <I>&lt;rvalue of type Ty&gt;</I></PRE><P>The macro yields the value of the next argument in order, specifiedby the context information designated by <CODE>ap</CODE>. The additionalargument must be of object type <CODE><I>Ty</I></CODE>after applying the rules for<A HREF="function.html#argument promotion">promoting arguments</A>in the absence of a function prototype.</P><H2><A NAME="va_end"><CODE>va_end</CODE></A></H2><PRE>#define <B>va_end</B>(va_list ap) <I>&lt;void expression&gt;</I></PRE><P>The macro performs any cleanup necessary,after processing the context information designated by<CODE>ap</CODE>, so that the function can return.</P><H2><A NAME="va_list"><CODE>va_list</CODE></A></H2><PRE>typedef <I>do-type</I> <B>va_list</B>;</PRE><P>The type is the object type <CODE><I>do-type</I></CODE> that you declareto hold the context information initialized by<A HREF="#va_start"><CODE>va_start</CODE></A> and used by<A HREF="#va_arg"><CODE>va_arg</CODE></A>to access additional unnamed arguments.</P><H2><A NAME="va_start"><CODE>va_start</CODE></A></H2><PRE>#define <B>va_start</B>(va_list ap, <I>last-par</I>) <I>&lt;void expression&gt;</I></PRE><P>The macro stores initial context information in the object designatedby <CODE>ap</CODE>. <CODE><I>last-par</I></CODE>is the name of the last parameter youdeclare. For example, <CODE><I>last-par</I></CODE>is <CODE>b</CODE> for the functiondeclared as <CODE>int f(int a, int b, ...)</CODE>. The last parameter mustnot have <CODE>register</CODE> storage class, and it must have a type thatis not changed by the translator. It cannot have:</P><UL><LI>an array type</LI><LI>a function type</LI><LI>type <I>float</I></LI><LI>any integer type that changes when promoted</LI><LI>a reference type <B>[C++ only]</B></LI></UL><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> &#169; 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 + -