Operating System - HP-UX
1830939 Members
2805 Online
110017 Solutions
New Discussion

How to pass NULL as an argument to a function which expects "va_list" type in HP-IA

 
vyssrayudu
New Member

How to pass NULL as an argument to a function which expects "va_list" type in HP-IA

Hi,

I am trying to compile a CPP program in HPIA64 using aCC 6.* compiler.

The function definition as below:
--------------------------------
void RtEventLog::
CopyMail(RtEventLog::LogEventSeverity Severity,
RtEventLog::mailTypes Type,
DWORD MsgId,
const TCHAR * MsgFmt,
va_list MsgArgs,
const TCHAR * MsgText)

Function call :
---------------
CopyMail(Severity, mailTypeText, 0, NULL, NULL, Text);

FYI : assuem #define NULL 0.

Now, When we pass NULL as an argument to the function call, it is being substituted as 0 and it is not getting converted into va_list type. Please help since it is very urgent.

We tried:
--------
Created an va_list variable as
va_list ap={};
CopyMail(Severity, mailTypeText, 0, (const TCHAR *)NULL, ap, Text);

But it did not work.


Thanks in Advance
3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: How to pass NULL as an argument to a function which expects "va_list" type on IA64

What you are doing is illegal and non-portable. You can not fiddle with a va_list since it is an opaque thingee. You can only pass it as a parm or assign (possibly with va_copy) or use it in other va_* functions.

In fact on x86-64, it is an array of a struct with 24 bytes.

>When we pass NULL as an argument to the function call, it is being substituted as 0 and it is not getting converted into va_list type.

It would help if you supplied the error message to make sure we are talking about the same thing.

>Created an va_list variable as: va_list ap={};
>But it did not work.

Not work how? That was kludge I have mentioned before. Of course you will have problems "testing" it.

vyssrayudu
New Member

Re: How to pass NULL as an argument to a function which expects "va_list" type in HP-IA

Hi,

Thanks for your response.. The original error which i got is pasted below.

./RtEvtLog.CPP", line 1340: error #2304: no instance of overloaded function "RtEventLog::CopyMail" matches the argument

list
argument types are: (RtEventLog::LogEventSeverity, RtEventLog::mailTypes, int, int, int, const TCHAR *)
CopyMail(Severity, mailTypeText, 0, 0, 0, Text);


Please suggest the solution to pass a NULL to the va_list..
Dennis Handly
Acclaimed Contributor

Re: How to pass NULL as an argument to a function which expects "va_list" type on IA64

>The original error

Yes, this is what you get if you have overloaded the function. What you are doing is illegal. There is no va_list constructor that takes an int.
I now need to see what you get for your "ap" workaround.

>Please suggest the solution to pass a NULL to the va_list..

As I said before, the Standard does NOT allow you to do this portably. You should consider some other mechanism. (Have you thought of how you are going to test for NULL?)