It’s looks like variable number of in macros are not supported by C++ compiler. I use PGI Workstation 7.1-4 (32-bit) to compile simple example with variadic macros…
#include <stdio.h>
//#define LOG(args...) printf("<LOG> " args)
#define LOG(arg, ...) printf("<LOG> " arg, __VA_ARGS__)
int main(int argc, char *argv[]) {
LOG("blah-blah %d!\n", 10);
return 0;
}
PGCC compile this code fine but PGCPP say some error messages…
C:\temp>pgcc -o a.exe a.c
C:\temp>pgcpp -o a.exe a.c
"d:/Program Files/PGI/Microsoft Open Tools 8/include/swprintf.inl", line 89: war
ning:
use of function "_vswprintf" (declared at line 506 of "d:/Program
Files/PGI/Microsoft Open Tools 8/include/stdio.h") is deprecated
int _Ret = _vswprintf(_String, _Format, _Arglist);
^
"d:/Program Files/PGI/Microsoft Open Tools 8/include/swprintf.inl", line 99: war
ning:
use of function "_vswprintf" (declared at line 506 of "d:/Program
Files/PGI/Microsoft Open Tools 8/include/stdio.h") is deprecated
return _vswprintf(_String, _Format, _Ap);
^
"d:/Program Files/PGI/Microsoft Open Tools 8/include/swprintf.inl", line 109: wa
rning:
use of function "__vswprintf_l" (declared at line 507 of "d:/Program
Files/PGI/Microsoft Open Tools 8/include/stdio.h") is deprecated
int _Ret = __vswprintf_l(_String, _Format, _Plocinfo, _Arglist);
^
"d:/Program Files/PGI/Microsoft Open Tools 8/include/swprintf.inl", line 119: wa
rning:
use of function "__vswprintf_l" (declared at line 507 of "d:/Program
Files/PGI/Microsoft Open Tools 8/include/stdio.h") is deprecated
return __vswprintf_l(_String, _Format, _Plocinfo, _Ap);
^
"a.c", line 5: error: expected an identifier
#define LOG(arg, ...) printf("<LOG> " arg, __VA_ARGS__)
^
"a.c", line 9: warning: too many arguments in macro invocation
LOG("blah-blah %d!\n", 10);
^
"a.c", line 9: error: identifier "__VA_ARGS__" is undefined
LOG("blah-blah %d!\n", 10);
^
2 errors detected in the compilation of "a.c".
With GCC and G++ (I use MinGW in Windows) this code works fine.
Can someone tell me how can I compile this code with PGI C++?