passing varargs to another function

I

Ian Partridge

Hi,

I want to write a varargs function which then passes its parameters to
another varargs function. I have RTFFAQ:

http://www.eskimo.com/~scs/C-faq/q15.12.html

which says that the other function should accept a va_list pointer to do
this. However, I can't seem to get this answer working.

Would someone mind posting a simple example of how this can be done?

Many thanks in advance,
Ian
 
D

Derk Gwen

# Hi,
#
# I want to write a varargs function which then passes its parameters to
# another varargs function. I have RTFFAQ:

static void plover(int x,...) {va_list L; va_start(L,x); etc;}
static void plugh(int x,...) {va_list L; va_start(L,x); plover(x,L); etc;}

This won't work. You need a version of plover that accepts a va_list.

static void vplover(int x,va_list L) {...}
static void plover(int x,...) {va_list L; va_start(L,x); vplover(x,L);}
static void plugh(int x,...) {va_list L; va_start(L,x); vplover(x,L); etc;}

# which says that the other function should accept a va_list pointer to do
# this. However, I can't seem to get this answer working.
#
# Would someone mind posting a simple example of how this can be done?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top