Hi all,
I am just courious with an implementation of preprocessor printf.
When possible I like to define a custom printf in order to always print the function name given by the
__FUNCTION__ macro, plus the string I have to print:
Code:
#define myprintf (...) { printf("[ %s ]" , __FUNCTION__); printf(__VA_ARGS__); printf("\n"); }
Is there a way to do it without using 3 separate printf ?
I tried with this one but his one is not valid:
Code:
#define myprintf(fmt, ...) printf("[ %s ] " fmt, __FUNCTION__, __VA_ARGS__);
because I cannot use with a single string without parameters. For example, the following:
Code:
myprintf("Hello world");
would not be compiled.
Thanks.