I need to wrap a macro so that it can be accessed with a function. The macro is defined like:
#define gDbgLog(fmt,...) dbgLog(g_pdbg,MODULE_NAME,__FUNCTION__,fmt,##__VA_ARGS__)
and I've attempted to wrap it up like:
void pMonDbgLog(char* fmt, ...)
{
va_list args;
va_start(args,fmt);
gDbgLog(fmt,args);
va_end(args);
}
while fmt
seems to come through fine, the arguments (int) seem to get clobbered up. I call it like:
int x = 51144;
pMonDbgLog("some text %d",x);
and what I get is "some text 642129608" while calling the macro directly like DbgLog("some text %d",x);
works fine. Why is this?
dbgLog()
wraps vsnprintf()
to generate the output.