Recursive Calls with Ellipses

E

Erik Zawadzki

I'm trying to write a wrapper functions for a function that uses the
stdarg.h ellipses notation for variable arguments. In essense, if the
original function is:

void foo(int n, ...){
//body
}

I want to write a function like:

void foo_wrapper (int n, ...){
//some stuff
foo(n, ##SOMETHING##);
//some other stuff
}

Where the ##SOMETHING## is exactly what satisfied the "...".
How do I do this? I tried naively giving "foo" a va_list, but that lead
to some fun segmentation errors. Any other thoughts?
 
C

Chris Torek

I'm trying to write a wrapper functions for a function that uses the
stdarg.h ellipses notation for variable arguments. ...

FAQ, 15.12.
In essense, if the original function is:

void foo(int n, ...){
//body
}

You will need a "vfoo" version, just like printf() and vprintf().
 
E

Eric Sosman

Erik said:
I'm trying to write a wrapper functions for a function that uses the
stdarg.h ellipses notation for variable arguments. In essense, if the
original function is:

void foo(int n, ...){
//body
}

I want to write a function like:

void foo_wrapper (int n, ...){
//some stuff
foo(n, ##SOMETHING##);
//some other stuff
}

Where the ##SOMETHING## is exactly what satisfied the "...".
How do I do this? I tried naively giving "foo" a va_list, but that lead
to some fun segmentation errors. Any other thoughts?

This is Question 15.12 in the comp.lang.c
Frequently Asked Questions (FAQ) list

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

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top