Some strange problem with macro overload in Visual Studio.
#define ENUM_INTERNAL(A, ...) A, ENUM_INTERNAL(__VA_ARGS__)
#define ENUM_INTERNAL(A) A, COUNT
#define ENUM(name, ...) struct name { enum en {ENUM_INTERNAL(__VA_ARGS__)}; };
ENUM(xxxx, A1, A2, A3)
static const xxxx::en x = xxxx::A3;
// All right, macro expanded into struct xxxx { enum en {A1, A2, A3, COUNT}; };
struct xxxx2 { enum en { ENUM_INTERNAL(A1, A2, A3) }; };
static const xxxx2::en x2 = xxxx2::A3;
// Compile error: no such member. struct xxxx2 { enum en {A1, COUNT}; };
As I understand, actually there is no macro overloading by number of arguments. But somehow it works in first case, when we pass arguments through __VA_ARGS__
expression. Why it happens?