variable argument list problem on HP-UX

A

Agile

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?
 
V

Victor Bazarov

Agile said:
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
 
J

Jack Klein

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.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top