Tech Support > Microsoft Windows > Development Resources > using variable arguments
using variable arguments
Posted by TheOne on May 15th, 2008


I read on a webpage ( http://wiki.kldp.org/wiki.php/CLangu...eArgumentsList
) that something like

#define debug(s, ...) fprintf(stderr, s, __VA_ARGS__)

void
foo(void)
{
debug("Entered the function, %s\n", __func__);
/* ... */
}

is possible. However my VC6.0 compiler errors that he doesn't
understand ... in macro. Is it impossible? Or would there be other way
to do this?

I want to add header in my debug message for each module. Something
like,

#define App1DebugWrapper(s, ...) DebugOutput( "app1", s, __VA_ARGS__)

DebugOutput is an OutputDebugString wrapper, which makes a long string
starting "app1 :" and hand the string to OutputDebugString.

TIA.

--
Daewon YOON

Posted by Nathan Mates on May 15th, 2008


In article <2a19ff06-7552-4209-aa11-318f6f70b10d@w8g2000prd.googlegroups.com>,
TheOne <daewon.yoon@gmail.com> wrote:
This is possible if you upgrade to Visual Studio 2005 or 2008. Not
possible in VC6. There's a lot of compiler improvements for
VS2005/2008 that are ver nice. The UI isn't quite as responsive as
VC6, and running your apps on other boxes is a new level of "fun" due
to manifest hell. (DLL hell on steriods.)

Nathan Mates
--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein