I have a variadic function from a third-party C library:
int func(int argc, ...);
argc indicates the number of passed optional
I came up with the following workaround for PP_NARG:
#define PP_NARG(...) (sizeof(#__VA_ARGS__) - 1 ? \
PP_NARG_(__VA_ARGS__, PP_RSEQ_N()) : 0)
It stringifies __VA_ARGS__, so if it's empty its length equals 1 (because #__VA_ARGS__ == '\0').
It works with -std=c99 -pedantic.
I still have problems with wrapping the variadic function though. When __VA_ARGS__ is empty, my_func expands to func(0, ) which triggers a compilation error.