reference to va_list

Discussion in 'C++' started by Rich Herrick, Jan 16, 2005.

  1. Rich Herrick

    Rich Herrick Guest

    Is it defined behavior to use a reference to a va_list to allow calling a
    function to extract arguments from the argument list, then upon returning to
    the calling function, continue extracting additional arguments. For
    example:

    int foo2(va_list& list)
    {
    return int(va_arg(list, int));
    }

    void foo(int x, ...)
    {
    va_list list;

    va_start(list, x);
    int a = foo2(list);
    int b = int(va_arg(list, int));
    va_end(list);

    printf("%d %d %d\n", x, a, b);
    }

    Ignoring why someone would do this, would calling foo(1, 2, 3) print the
    values of the three variables x, a, and b as 1, 2, and 3, respectively?

    Thanks,

    --
    Rich Herrick
    http://www.richherrick.com
    Rich Herrick, Jan 16, 2005
    #1
    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. va_list in JNI

    , Jun 23, 2005, in forum: Java
    Replies:
    4
    Views:
    2,304
  2. Peter

    va_list help, please ...

    Peter, Feb 15, 2005, in forum: C++
    Replies:
    6
    Views:
    3,533
    Pete Becker
    Feb 15, 2005
  3. John Guo

    va_list help

    John Guo, Mar 31, 2005, in forum: C++
    Replies:
    5
    Views:
    3,305
    Pete Becker
    Mar 31, 2005
  4. Vaclav Haisman
    Replies:
    2
    Views:
    1,107
    Vaclav Haisman
    May 15, 2010
  5. Urs Thuermann

    Passing va_list by reference to a function

    Urs Thuermann, Nov 22, 2010, in forum: C Programming
    Replies:
    7
    Views:
    1,727
    Urs Thuermann
    Nov 23, 2010
Loading...

Share This Page