Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

printf like behaviour?

Tags:

c

macos

I have a function as below

extern "C" int FuncTrace(const char *fmt, ...)
{
    va_list args;
    va_start(args, fmt);
    return printf(fmt, args);
}

If I print some thing on console as below, it does not work?

FuncTrace(" %s  \n", __PRETTY_FUNCTION__ );

Can someone help me correct the FuncTrace() ?

like image 452
RLT Avatar asked Feb 21 '23 23:02

RLT


1 Answers

You need the vprintf function if you want to pass in a va_list pseudo-argument:

return vprintf(fmt, args);
like image 53
Niklas B. Avatar answered Feb 27 '23 16:02

Niklas B.