Hi,
I would like to write a function which wraps the printf(const char*, ...), in order to turn off it accroding to a macro definition, since I have a lot of debug information to be printed out, but it affects the performance of the program if I don't need debug any more.
The following function is what I wrote, but it does not work for other format output than the single string.
if I call pn_report("ok"), it is fine, but if I call pn_report("%d", var), it is not ok.
any help on writing this function? Is there any other way to do this?
Thanks in advance.
/Kenny
I would like to write a function which wraps the printf(const char*, ...), in order to turn off it accroding to a macro definition, since I have a lot of debug information to be printed out, but it affects the performance of the program if I don't need debug any more.
The following function is what I wrote, but it does not work for other format output than the single string.
Code:
int pn_report(const char *format, ...) {
#ifdef PN_DEBUG
return printf(format);
#else
return 0;
#endif
}
if I call pn_report("ok"), it is fine, but if I call pn_report("%d", var), it is not ok.
any help on writing this function? Is there any other way to do this?
Thanks in advance.
/Kenny