点击查看代码
#define FOO(name) (uint64_t)name ,
#define EMPTY()
#define DEFER(id) id EMPTY()
#define FOR_EACH(macro, x, ...) CAT(FOR_EACH_, ff(__VA_ARGS__)) (macro, x, ## __VA_ARGS__)
#define FOR_EACH_0(macro, x, ...) macro(x) DEFER(FOR_EACH_I)() (macro, __VA_ARGS__)
#define FOR_EACH_1(m, x) m(x)
#define FOR_EACH_I() FOR_EACH
#define _PRIMITIVE_CAT(x, y) x ## y
#define CAT(x, y) _PRIMITIVE_CAT(x, y)
#define EVAL(...) EVAL1(EVAL1(EVAL1(__VA_ARGS__)))
#define EVAL1(...) EVAL2(EVAL2(EVAL2(__VA_ARGS__)))
#define EVAL2(...) EVAL3(EVAL3(EVAL3(__VA_ARGS__)))
#define EVAL3(...) EVAL4(EVAL4(EVAL4(__VA_ARGS__)))
#define EVAL4(...) EVAL5(EVAL5(EVAL5(__VA_ARGS__)))
#define EVAL5(...) __VA_ARGS__
#define ff(...) _ff(0, ## __VA_ARGS__, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)
#define _ff(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, N,...) N
#define log(x) kk x
#define kk(...) CAT(kk_, ff(__VA_ARGS__)) (__VA_ARGS__)
#define kk_1(...) ({})
#define kk_0(...) ({ uint64_t a[] = { EVAL(FOR_EACH(FOO, ## __VA_ARGS__ )) } ;\
printf("%d uu", sizeof(a)/sizeof(uint64_t));\
})