Question

I use the ROOT C++ libraries (root.cern.ch) daily and was browsing the source when I came across this function declaration:

TString TString::Format(const char *va_(fmt), ...)
{
    //etc.

It can be found here.

I don't understand how a const char * can have an argument or a parenthesis in its name. The expression va_(fmt) is later used as a simple const char * even though it looks like a function call or a constructor. At first I thought it had something to do with the variable argument list, which was also new to me, but reading documentation on stdarg.h didn't help with this question at all.

It is very hard to google for help since I'm not really sure what to call this. A declaration with an argument? That doesn't give any good results.

I used to think I knew C++, but what is going on here? All help will be appreciated.

Was it helpful?

Solution

It's a macro - in Varargs.h:

#if ...
#  define va_(arg) __builtin_va_alist
#else
#  define va_(arg) arg
#endif
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top