Operating System - HP-UX
1822230 Members
3723 Online
109642 Solutions
New Discussion юеВ

how can we assign NULL value to va_list variable in HPUX itanium..

 
rakeshcs123
Advisor

how can we assign NULL value to va_list variable in HPUX itanium..

Hi Guys,
I have written a function which takes variable argument as one of the input, and i want to pass NULL argument in as input, but getting following error message
Illegal cast expression; cannot cast expression type 'long' to '__va_list__

can you please help me resolving the problem.

function is of type
fun(char *a, va_list valist);
and calling function call it as
fun(a,NULL);

Thanks for the help in advance...
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: how can we assign NULL value to va_list variable in HPUX itanium..

(This has nothing to do with sys admin, languages is the proper forum.)

Since va_list is a thingy, you can't assign a NULL. Basically va_list is a C++ class that has no constructors, no operator==, no operator void*, etc. It only has copy constructor and copy assignment operator.
You can only use va_start, va_arg, (va_copy on C99) and va_end. See the following:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1207141

The only way to initialize to 0 is with a hammer for lvalues or a static variable or with this C++ construct for locals: va_list ap = {};
rakeshcs123
Advisor

Re: how can we assign NULL value to va_list variable in HPUX itanium..

Thanks for your reply...
I just checked the link
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1207141

and have a doubt here. If i use sth like
#ifdef FIX
static va_list va_NULL;
#endif
#ifdef FIX
void sam(va_list ap = va_NULL)
#else
void sam(va_list ap = NULL)
#endif

and if try to use va_list variable ap with va_args, will it work properly since we have not initialized static variable va_NULL but have assigned it to va_list variable ap. If it works properly i think it will solve my problem, if not how to deal with this scenario.

Thanks in advance
Dennis Handly
Acclaimed Contributor

Re: how can we assign NULL value to va_list variable in HPUX itanium..

>if try to use va_list variable ap with va_args, will it work properly since we have not initialized static variable va_NULL

Static POD variables are default initialized to 0.
You will have similar problems testing your parm against NULL.
rakeshcs123
Advisor

Re: how can we assign NULL value to va_list variable in HPUX itanium..

Thanks for the help. It seems this will really help.
Dennis Handly
Acclaimed Contributor

Re: how can we assign NULL value to va_list variable in HPUX itanium..

>Thanks for the help. It seems this will really help.

If this answers your questions, you should read the following about assigning points and reopening threads:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
http://forums.itrc.hp.com/service/forums/helptips.do?#41