Skip to content

Instantly share code, notes, and snippets.

@vaualbus
Created May 1, 2020 19:58
Show Gist options
  • Save vaualbus/54f335bdd69728d352a5d2ec429a175e to your computer and use it in GitHub Desktop.
Save vaualbus/54f335bdd69728d352a5d2ec429a175e to your computer and use it in GitHub Desktop.
#if COMPILER_MSVC
#define MSVC_HACK(FUNC, ARGS) FUNC ARGS
#define APPLY(FUNC, ...) MSVC_HACK(FUNC, (__VA_ARGS__))
#define VA_LENGTH(...) APPLY(VA_LENGTH_, 0, ## __VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#else
#define VA_LENGTH(...) VA_LENGTH_(0, ## __VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#endif
#define VA_LENGTH_(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, N, ...) N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment