Advertisement

05.27.2008 at 01:15PM PDT, ID: 23436216
[x]
Attachment Details

Detecing an empty va_list?

Asked by _Stilgar_ in C++ Programming Language, C Programming Language, Microsoft Visual C++

Hi all,

I have a function that accepts an LPCTSTR. I want to add functionality to parameterized strings - that is, to have the LPCTSTR go through _vsntprint - but since it requires copying the string to a buffer, or making the current buffer larger, I want to call it only if the parameters list is not empty. I would want to use the same function I do now, without creating another version of it which accepts an ellipsis.

So, if my function looks like this: int Execute (LPCTSTR command) , I want it to look like this: int Execute (LPCTSTR command, ...). I'm then using va_start, but couldn't figure out how to see if it points to an empty parameters list or not. I'm not even sure using va_arg is possible for testing this (of course I will have to do va_list args-- after calling it). Passing an int with parameters count is not an option.

Any advice on how to do this (if at all possible)?

Stilgar.Start Free Trial
 
Loading Advertisement...
 
[+][-]05.27.2008 at 01:36PM PDT, ID: 21655464

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C++ Programming Language, C Programming Language, Microsoft Visual C++
Sign Up Now!
Solution Provided By: jkr
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.28.2008 at 08:30PM PDT, ID: 21666106

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906