how could I write this cpp macro



Hi,

I'm trying to convert this:

printf("format str %s, %s", "str arg 1", "str arg 2 etc.");

to this:

printf("%s: " "format str %s, %s", __FUNCTION__, "str arg 1", "str arg2
etc.");

All sol'ns I came up had various problems in various printf formats.
The closest I had was something like:

#if DEBUG > 0
#define pdebug(fmt ...) printf("%s: " fmt, \
__FUNCTION__, __VA_ARGS__); \
#endif

But this wont work if there's a printf with no va_args, such as:

printf("fmt string and nothing else\n");

because the comma after __FUNCTION__ will be a syntax error.

Any ideas?

Thanks,
Bahadir

.