473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

variable argument list problem on HP-UX

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?

Nov 23 '06 #1
2 1603
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
Nov 23 '06 #2
On 22 Nov 2006 17:07:30 -0800, "Agile" <mi*******@gmail.comwrote 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/~a...FAQ-acllc.html
Nov 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Philip Rittenhouse | last post by:
I have discovered a couple of problems with the way the universal gateway code handles optional parameters and variable argument lists in COM servers. It appears to only be a problem when you...
2
by: Suzanne Vogel | last post by:
'stdarg.h' defines the 'va_arg' type to use in passing variable numbers of parameters to functions. The example of its use given in the Dinkumware documentation *seems* to imply that the 'va_arg'...
7
by: Kapt. Boogschutter | last post by:
I'm trying to create a function that has at least 1 Argument but can also contain any number of Arguments (except 0 because my function would have no meaning for 0 argument). The arguments...
7
by: | last post by:
How to call a function with variable argument list from another function again with variable argument list? Example : double average ( int num, ... ); double AFunct1 ( int num, ... ); double...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
3
by: zoe | last post by:
I am trying to master the variable argument list! C99 tells me: 7.15.1.4 The va_start macro: 1 #include <stdarg.h> void va_start(va_list ap, parmN); 4 The parameter parmN is the...
5
by: Jonathan Burd | last post by:
Greetings everyone, I wrote a function to learn about variable-length argument lists. I wonder if there is a better way to detect the end of the argument list than using a sentinel value like...
1
by: Nimmi Srivastav | last post by:
Consider two functions A and B, both of which accept a variable number of arguments (va_start, va-arg, va_end). Is there an easy way for arguments passed to A to be, in turn, passed to B? (For...
19
by: Spiros Bousbouras | last post by:
Every time I've seen an example of a variable argument list function its functionality was to print formatted output. Does anyone have examples where the function is not some variation of printf ?
30
by: Adam | last post by:
Hi, I have a simple printf-like function: int print(const char *format, ...) { char buffer; va_list argptr; int i;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.