I have the following function foo()
and the macro FOO(str)
.
void foo(const char *fmt, ...) {
va_list args;
va_start(args,fmt);
vsprintf(msgbuff,fmt,args);
va_end(args);
printf("%s\n",msgbuff);
}
#define FOO(str)\
foo str; // No need of brackets as they are coming in 'str'
I used to call the macro like below:
FOO(("My %s is %s\n","Name","Bala"));
Now my Requirement is:
Macro FOO(str)
should not call my function foo()
directly but instead it should call it through another function like func()
.
Finally my macro should be like below
#define FOO(str)\
func(#str) // Do I need to Stringizing str?
My question is, how can I call function foo()
from inside func()
?
Please suggest any possible implementation.
func()
.