Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please help me understand this C++ parameter declaration with an argument

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.

like image 884
Simon Avatar asked Mar 20 '12 14:03

Simon


1 Answers

It's a macro - in Varargs.h:

#if ...
#  define va_(arg) __builtin_va_alist
#else
#  define va_(arg) arg
#endif
like image 83
JoeG Avatar answered Oct 21 '22 23:10

JoeG