variable argument list problem on HP-UX

Discussion in 'C++' started by Agile, Nov 23, 2006.

  1. Agile

    Agile Guest

    I have a simple function that takes variable argument list, the sample
    code
    is below:

    func1( char* a, ...)
    {
    va_list arg_list;
    va_start(arg_list,a);

    // do something with arg_list

    va_end(arg_list);
    }

    It worked on Windows and SUN OS, but on HP-UX the arg_list is NULL
    after "va_start".
    Seems like arg_list is not being initialized. Any ideas?
     
    Agile, Nov 23, 2006
    #1
    1. Advertising

  2. Agile wrote:
    > I have a simple function that takes variable argument list, the sample
    > code
    > is below:
    >
    > func1( char* a, ...)
    > {
    > va_list arg_list;
    > va_start(arg_list,a);
    >
    > // do something with arg_list
    >
    > va_end(arg_list);
    > }
    >
    > It worked on Windows and SUN OS, but on HP-UX the arg_list is NULL
    > after "va_start".
    > Seems like arg_list is not being initialized. Any ideas?


    What does it mean that 'arg_list' is NULL? The contents of it are
    implementation-defined. The Standard doesn't say what they should
    be in any situation.

    Read FAQ, especially 5.8. Somebody with access to aCC might be able
    to help. If not, contact HP. After all, if you have it, you must
    have technical support information, use it.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Nov 23, 2006
    #2
    1. Advertising

  3. Agile

    Jack Klein Guest

    On 22 Nov 2006 17:07:30 -0800, "Agile" <> wrote in
    comp.lang.c++:

    > I have a simple function that takes variable argument list, the sample
    > code
    > is below:
    >
    > func1( char* a, ...)
    > {
    > va_list arg_list;
    > va_start(arg_list,a);
    >
    > // do something with arg_list
    >
    > va_end(arg_list);
    > }
    >
    > It worked on Windows and SUN OS, but on HP-UX the arg_list is NULL
    > after "va_start".
    > Seems like arg_list is not being initialized. Any ideas?


    You haven't shown us code that calls the function, and most
    importantly of all, you have not told us whether or not there is a
    correct prototype, with the ellipsis, in scope at the point of the
    call.

    Calling a variadic argument without a correct prototype in scope
    produces undefined behavior, and there are definitely platforms where
    it will not work.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://c-faq.com/
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Nov 23, 2006
    #3
    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. Ben Kial
    Replies:
    1
    Views:
    662
    Eric Enright
    Nov 15, 2004
  2. S?ren Gammelmark
    Replies:
    1
    Views:
    1,895
    Eric Sosman
    Jan 7, 2005
  3. Joakim Hove
    Replies:
    5
    Views:
    519
    Joakim Hove
    Mar 14, 2008
  4. AikidoGuy
    Replies:
    11
    Views:
    560
    Seebs
    Nov 21, 2011
  5. Dave Slayton
    Replies:
    1
    Views:
    194
    Ben Morrow
    Mar 11, 2007
Loading...

Share This Page