<s>
stdarg.h	B-Language
is	O
a	O
header	O
in	O
the	B-Language
C	I-Language
standard	I-Language
library	I-Language
of	O
the	O
C	B-Language
programming	I-Language
language	I-Language
that	O
allows	O
functions	O
to	O
accept	O
an	B-Language
indefinite	I-Language
number	I-Language
of	I-Language
arguments	I-Language
.	O
</s>
<s>
C++	B-Language
provides	O
this	O
functionality	O
in	O
the	O
header	O
cstdarg	B-Language
.	O
</s>
<s>
The	O
contents	O
of	O
stdarg.h	B-Language
are	O
typically	O
used	O
in	O
variadic	B-Language
functions	I-Language
,	O
though	O
they	O
may	O
be	O
used	O
in	O
other	O
functions	O
(	O
for	O
example	O
,	O
vprintf	O
)	O
called	O
by	O
variadic	B-Language
functions	I-Language
.	O
</s>
<s>
Variadic	B-Language
functions	I-Language
are	O
functions	O
which	O
may	O
take	O
a	O
variable	O
number	O
of	O
arguments	O
and	O
are	O
declared	O
with	O
an	O
ellipsis	O
in	O
place	O
of	O
the	O
last	O
parameter	O
.	O
</s>
<s>
An	O
example	O
of	O
such	O
a	O
function	O
is	O
printf	B-Language
.	O
</s>
<s>
Variadic	B-Language
functions	I-Language
must	O
have	O
at	O
least	O
one	O
named	O
parameter	O
,	O
so	O
,	O
for	O
instance	O
,	O
</s>
<s>
is	O
not	O
allowed	O
in	O
C	B-Language
.	O
(	O
In	O
C++	B-Language
and	O
the	O
upcoming	O
C23	B-Language
,	O
such	O
a	O
declaration	O
is	O
permitted	O
.	O
)	O
</s>
<s>
In	O
C	B-Language
,	O
a	O
comma	O
must	O
precede	O
the	O
ellipsis	O
if	O
a	O
named	O
parameter	O
is	O
specified	O
;	O
in	O
C++	B-Language
,	O
it	O
is	O
optional	O
.	O
</s>
<s>
To	O
access	O
the	O
unnamed	O
arguments	O
,	O
one	O
must	O
declare	O
a	O
variable	O
of	O
type	O
va_list	O
in	O
the	O
variadic	B-Language
function	I-Language
.	O
</s>
<s>
In	O
C23	B-Language
the	O
second	O
argument	O
will	O
be	O
optional	O
and	O
will	O
not	O
be	O
evaluated	O
.	O
</s>
<s>
C99	B-Language
provides	O
an	O
additional	O
macro	O
,	O
va_copy	O
,	O
which	O
can	O
duplicate	O
the	O
state	O
of	O
a	O
va_list	O
.	O
</s>
<s>
Use	O
of	O
a	O
printf	B-Language
or	O
scanf-like	O
format	B-Language
string	I-Language
with	O
embedded	O
specifiers	O
that	O
indicate	O
argument	O
types	O
.	O
</s>
<s>
A	O
sentinel	B-Data_Structure
value	I-Data_Structure
at	O
the	O
end	O
of	O
the	O
variadic	O
arguments	O
.	O
</s>
<s>
Because	O
the	O
size	O
of	O
the	O
unnamed	O
argument	O
list	O
is	O
generally	O
unknown	O
(	O
the	O
calling	O
conventions	O
employed	O
by	O
most	O
compilers	O
do	O
not	O
permit	O
determining	O
the	O
size	O
of	O
the	O
unnamed	O
argument	O
block	O
pointed	O
at	O
by	O
va_list	O
inside	O
the	O
receiving	O
function	O
)	O
,	O
there	O
is	O
also	O
no	O
reliable	O
,	O
generic	O
way	O
to	O
forward	O
the	O
unnamed	O
arguments	O
into	O
another	O
variadic	B-Language
function	I-Language
.	O
</s>
<s>
Even	O
where	O
determining	O
the	O
size	O
of	O
the	O
argument	O
list	O
is	O
possible	O
by	O
indirect	O
means	O
(	O
for	O
example	O
,	O
by	O
parsing	O
the	O
format	B-Language
string	I-Language
of	O
fprintf( )	O
)	O
,	O
there	O
is	O
no	O
portable	O
way	O
to	O
pass	O
the	O
dynamically	O
determined	O
number	O
of	O
arguments	O
into	O
the	O
inner	O
variadic	O
call	O
,	O
as	O
the	O
number	O
and	O
size	O
of	O
arguments	O
passed	O
into	O
such	O
calls	O
must	O
generally	O
be	O
known	O
at	O
compile	O
time	O
.	O
</s>
<s>
To	O
some	O
extent	O
,	O
this	O
restriction	O
can	O
be	O
relaxed	O
by	O
employing	O
variadic	B-Language
macros	I-Language
instead	O
of	O
variadic	B-Language
functions	I-Language
.	O
</s>
<s>
A	O
user-defined	O
variadic	B-Language
function	I-Language
can	O
therefore	O
initialize	O
a	O
va_list	O
variable	O
using	O
va_start	O
and	O
pass	O
it	O
to	O
an	O
appropriate	O
standard	O
library	O
function	O
,	O
in	O
effect	O
passing	O
the	O
unnamed	O
argument	O
list	O
by	O
reference	O
instead	O
of	O
doing	O
it	O
by	O
value	O
.	O
</s>
<s>
Because	O
there	O
is	O
no	O
reliable	O
way	O
to	O
pass	O
unnamed	O
argument	O
lists	O
by	O
value	O
in	O
C	B-Language
,	O
providing	O
variadic	O
API	B-Application
functions	I-Application
without	O
also	O
providing	O
equivalent	O
functions	O
accepting	O
va_list	O
instead	O
is	O
considered	O
a	O
bad	O
programming	O
practice	O
.	O
</s>
<s>
Some	O
C	B-Language
implementations	O
provide	O
C	B-Language
extensions	O
that	O
allow	O
the	O
compiler	O
to	O
check	O
for	O
the	O
proper	O
use	O
of	O
format	B-Language
strings	I-Language
and	O
sentinels	O
.	O
</s>
<s>
Therefore	O
,	O
care	O
should	O
be	O
taken	O
to	O
ensure	O
correctness	O
in	O
this	O
regard	O
,	O
since	O
undefined	B-Language
behavior	I-Language
results	O
if	O
the	O
types	O
do	O
not	O
match	O
.	O
</s>
<s>
GCC	B-Application
has	O
an	O
extension	O
that	O
checks	O
the	O
passed	O
arguments	O
:	O
</s>
<s>
Outdated	O
versions	O
of	O
POSIX	O
defined	O
the	O
legacy	O
header	O
varargs.h	O
,	O
which	O
dates	O
from	O
before	O
the	O
standardization	O
of	O
C	B-Language
and	O
provides	O
functionality	O
similar	O
to	O
stdarg.h.	O
</s>
<s>
This	O
header	O
is	O
part	O
of	O
neither	O
ISO	O
C	B-Language
nor	O
POSIX	O
.	O
</s>
<s>
The	O
file	O
,	O
as	O
defined	O
in	O
the	O
second	O
version	O
of	O
the	O
Single	O
UNIX	O
Specification	O
,	O
simply	O
contains	O
all	O
of	O
the	O
functionality	O
of	O
C89	O
stdarg.h	B-Language
,	O
with	O
the	O
exceptions	O
that	O
:	O
</s>
<s>
varargs.h	O
requires	O
old-style	O
function	O
definitions	O
because	O
of	O
the	O
way	O
the	O
implementation	O
works	O
.	O
</s>
<s>
Conversely	O
,	O
it	O
is	O
not	O
possible	O
to	O
mix	O
old-style	O
function	O
definitions	O
with	O
stdarg.h.	O
</s>
