http://en.wikipedia.org/wiki/Variadic_macro:
GCC supports the following (non-portable) extension: ## __VA_ARGS__
c++ Variadic Macro Compile error
题
Following the stackoverflow question: "Variadic macros with zero arguments, and commas", I tried:
#define MAKE_TEMPLATE(...) template <typename T, ## __VA_ARGS__ >
MAKE_TEMPLATE()
struct Testing{};
Compiler gives: error: expected identifier before '>' token
But g++ -E main.cpp (to get macro expansion) show:
template <typename T >
struct Testing{};
And with:
MAKE_TEMPLATE(typename U)
struct Testing{};
It compile OK. Whats missing?
解决方案
不隶属于 StackOverflow