I would like to expand a variadic macro to another macro that takes a single argument, which is formed by joining the variadic arguments with a delimiter/separator (e.g. "_"). Something like this:
#define FOO(...)
FOO(a, b, c, d);
which expands into
#define BAR(X)
BAR(a_b_c_d);
I know there is __VA_ARGS__
for working with the variadic parameters, and ##
for concatenation. How do I use them together to achieve what I want (preferably using C++17 and older language features, without libraries such as Boost)?