A
Allan Bruce
Is there a way to make a pre-processor define with a variable number of
arguements? I want to have something like this:
#define DBG_WRITE(char *A, ...)
{
va_list vl;
char dbgTmpStr[1024];
va_start(vl, A);
vsprintf(dbgTmpStr, A, vl);
va_end(vl);
fprintf(gDbgFP, dbgTmpStr);
fflush(gDbgFP);
}
But this obviously doesnt compile.
At the moment I have DBG_WRITE0 for no additional params, DB_WRITE1 for 1
additional param and so on which is quite messy.
I can make a define that works for printf like this:
#define DBG_PRINTF(A) printf A;
and then I just call it like this: DBG_PRINTF(("Hello %s\n, someName));
(note the double brackets).
Is there a way I can achieve this for fprintf()?
Thanks,
Allan
arguements? I want to have something like this:
#define DBG_WRITE(char *A, ...)
{
va_list vl;
char dbgTmpStr[1024];
va_start(vl, A);
vsprintf(dbgTmpStr, A, vl);
va_end(vl);
fprintf(gDbgFP, dbgTmpStr);
fflush(gDbgFP);
}
But this obviously doesnt compile.
At the moment I have DBG_WRITE0 for no additional params, DB_WRITE1 for 1
additional param and so on which is quite messy.
I can make a define that works for printf like this:
#define DBG_PRINTF(A) printf A;
and then I just call it like this: DBG_PRINTF(("Hello %s\n, someName));
(note the double brackets).
Is there a way I can achieve this for fprintf()?
Thanks,
Allan