Recursive Calls with Ellipses

Discussion in 'C++' started by Erik Zawadzki, Nov 12, 2004.

  1. 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?
    Erik Zawadzki, Nov 12, 2004
    #1
    1. Advertising

  2. Erik Zawadzki wrote:
    > 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?


    There is no way. Create a common function that will accept the va_list,
    and call it from both 'foo' and 'foo_wrapper'.

    V
    Victor Bazarov, Nov 12, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RCS
    Replies:
    3
    Views:
    2,801
    Jeff User
    Dec 2, 2005
  2. Nathan Sokalski

    Why so much trouble with ellipses?

    Nathan Sokalski, Jan 13, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    336
    Peter Proost
    Jan 17, 2006
  3. Erik Zawadzki

    Recursive Calls with Ellipses

    Erik Zawadzki, Nov 12, 2004, in forum: C Programming
    Replies:
    2
    Views:
    369
    Eric Sosman
    Nov 12, 2004
  4. hyperboogie
    Replies:
    18
    Views:
    392
    David Thompson
    Apr 15, 2007
  5. n00m
    Replies:
    12
    Views:
    1,103
Loading...

Share This Page