forked from debrouxl/gcc4ti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stdarg.html
99 lines (90 loc) · 5.51 KB
/
stdarg.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>stdarg.h</TITLE>
<STYLE TYPE="TEXT/CSS">
<!--
.IE3-DUMMY { CONT-SIZE: 100%; }
BODY { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #E0E0E0; }
P { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
H1 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
H2 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
H3 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
H4 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
H5 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
H6 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
UL { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
TD { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #FFFFFF; }
.NOBORDER { BACKGROUND-COLOR: #E0E0E0; PADDING: 0pt; }
.NOBORDER TD { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #E0E0E0; PADDING: 0pt; }
.CODE { FONT-FAMILY: Courier New; }
-->
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#E0E0E0">
<FONT SIZE="5"><B>The <stdarg.h> Header File</B></FONT>
<HR>
<P><B>ANSI routines for creating functions with variable numbers of arguments</B></P>
<H3><U>Functions</U></H3>
<DL INDENT="20"><DT><B><A HREF="#va_arg">va_arg</A></B><DD>Returns the current argument in the list.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#va_end">va_end</A></B><DD>va_end helps the called function perform a normal return.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#va_start">va_start</A></B><DD>Initializes a pointer to a variable argument list.</DL>
<H3><U>Predefined Types</U></H3>
<DL INDENT="20"><DT><B><A HREF="#va_list">va_list</A></B><DD>A void pointer which can be interpreted as an argument list.</DL>
<HR>
<H3><A NAME="va_arg"><U>va_arg</U></A></H3>
<P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE">type va_arg (<A HREF="#va_list">va_list</A> &ap, type);</TD></TR></TABLE></P>
<P><B>Returns the current argument in the list.</B></P>
<P>This function (also implemented as a macro) expands to an expression that
has the same type and value as the next argument being passed (one of the
variable arguments). The variable <I>ap</I> to va_arg should be the same
<I>ap</I> that <A HREF="#va_start">va_start</A> initialized. Because of
default promotions, you can't use char or unsigned char types with va_arg.
<BR><BR>
The first time va_arg is used, it returns the first argument in the list. Each
successive time va_arg is used, it returns the next argument in the list. It
does this by first dereferencing <I>ap</I>, and then incrementing <I>ap</I>
to point to the following item.
<BR><BR>
va_arg uses the parameter <I>type</I> (which must be an expected type name) to both
perform the dereference and to locate the following item. Each successive time va_arg
is invoked, it modifies ap to point to the next argument in the list.</P>
<HR>
<H3><A NAME="va_end"><U>va_end</U></A></H3>
<P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#void">void</A></B> va_end (<A HREF="#va_list">va_list</A> &ap);</TD></TR></TABLE></P>
<P><B>va_end helps the called function perform a normal return.</B></P>
<P>va_end might modify <I>ap</I> in such a way that it cannot be used unless
<A HREF="#va_start">va_start</A> is recalled. va_end should be called
after <A HREF="#va_arg">va_arg</A> has read all the arguments.
<BR><BR>
<B>Note:</B> va_end is introduced here only to increase compatibility with ANSI C. In this
implementation, va_end in fact does nothing.</P>
<HR>
<H3><A NAME="va_start"><U>va_start</U></A></H3>
<P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#void">void</A></B> va_start (<A HREF="#va_list">va_list</A> &ap, &lastfix);</TD></TR></TABLE></P>
<P><B>Initializes a pointer to a variable argument list.</B></P>
<P>Some C functions, such as sprintf have a variable number of arguments. This
function, together with <A HREF="#va_arg">va_arg</A> and <A HREF="#va_end">va_end</A>,
provides a portable way to access
these argument lists. They are used for stepping through a list of arguments
when the called function does not know the number and types of the arguments
being passed. Function va_start (implemented as a macro) sets <I>ap</I> to point to the
first of the variable arguments being passed to the function. It must be
used before the first call to <A HREF="#va_arg">va_arg</A> or <A HREF="#va_end">va_end</A>.
<BR><BR>
va_start takes two parameters: <I>ap</I> and <I>lastfix</I>. <I>ap</I> is explained
above, and <I>lastfix</I> is the name of the last fixed parameter being passed to the
called function.
<BR><BR>
<B>Note:</B> I used notation "&<I>ap</I>" in the prototype description, although passing by
reference does not exist in ordinary C (only in C++). However, this macro is implemented
in such a way that it simulates "passing by reference".</P>
<HR>
<H3><A NAME="va_list"><U>va_list</U></A></H3>
<P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#typedef">typedef</A></B> <B><A HREF="keywords.html#void">void</A></B> *va_list;</TD></TR></TABLE></P>
<P><B>A void pointer which can be interpreted as an argument list.</B></P>
<P>va_list is the type of the void pointer passed to one of the functions that accepts a
pointer to a list of arguments. This array holds information needed by
<A HREF="#va_arg">va_arg</A> and <A HREF="#va_end">va_end</A>.</P>
<HR>
<H3><A HREF="index.html">Return to the main index</A></H3>
</BODY>
</HTML>