This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: variadic function
- From: Pierre Laplante <laplante at sednove dot com>
- To: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- Cc: Pierre Laplante <laplante at sednove dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Sun, 19 Oct 2003 10:08:41 -0400 (EDT)
- Subject: Re: variadic function
Here is the answer:
In general, you cannot. Ideally, you should provide a version of that
other function which accepts a va_list pointer (analogous to vfprintf;
see question 15.5). If the arguments must be passed directly as actual
arguments, or if you do not have the option of rewriting the second
function to accept a va_list (in other words, if the second, called
function must accept a variable number of arguments, not a va_list), no
portable solution is possible. (The problem could perhaps be solved by
resorting to machine-specific assembly language; see also question
15.13.)
which is somewhat limited!
On 19 Oct 2003, Falk Hueffner wrote:
> Pierre Laplante <laplante@sednove.com> writes:
>
> > If I want to implement a function
> >
> > f1(char *fmt, ...) {
> > f2(fmt, ...);
> > }
> >
> > where f2 is defined as
> >
> > f2(char *fmt, ...) {
> > }
> >
> > that want to call f2 which is itself a variadic function. How can
> > I implement this using stdarg?
>
> See the C FAQ (www.eskimo.com/~scs/C-faq/top.html)
>
>