I\'ve got the following macros
#include
#define DB_FIELD(...) BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)
#define DB_TOFIELD(type,name
What you are running into is an exception to how the preprocessor expands parameters if they are arguments to the #
or ##
operators. From C++.2011 §16.3.1¶1:
After the arguments for the invocation of a function-like macro have been identified, argument substitution takes place. A parameter in the replacement list, unless preceded by a
#
or##
preprocessing token or followed by a##
preprocessing token (see below), is replaced by the corresponding argument after all macros contained therein have been expanded. Before being substituted, each argument’s preprocessing tokens are completely macro replaced as if they formed the rest of the preprocessing file; no other preprocessing tokens are available.
The macro indirection avoids the exception clause, causing the argument to be expanded before being processed by the other macro.
For example:
#define FOO 10
#define BAR(x) x ## 7
#define BAR2(x) BAR(x)
int x = BAR(FOO); // => int x = FOO7;
int y = BAR2(FOO); // => int y = BAR(10); (intermediate result)
// => int y = 107; (final expansion)