//The example below works
//The idea is taken here:
https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/#include <stdio.h>
#define ARGS_COUNT(...) _ARGS_COUNT3(_ARGS_COUNT_EMPTY(__VA_ARGS__), __VA_ARGS__)
#define _ARGS_COUNT3(_1,...) _ARGS_COUNT4(_1,__VA_ARGS__)
#define _ARGS_COUNT4(_1,...) _ARGS_COUNT##_1(__VA_ARGS__)
#define _ARGS_COUNT(...) _ARGS_COUNT2(__VA_ARGS__,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
#define _ARGS_COUNT0(...) _ARGS_COUNT2(__VA_ARGS__,15,14,13,12,11,10,9,8,7,6,5,4,3,2,0,0)
#define _ARGS_COUNT2(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15, ...) _15
#define _ARGS_COMMA(...) ,
#define _ARGS_COUNT_EMPTY(...) _ARGS_COUNT_EMPTY1(__VA_ARGS__,)
#define _ARGS_COUNT_EMPTY1(_1,...) _ARGS_COUNT_EMPTY2(_ARGS_COMMA##_1())
#define _ARGS_COUNT_EMPTY2(...) _ARGS_COUNT_EMPTY3(__VA_ARGS__,0,,)
#define _ARGS_COUNT_EMPTY3(_1,_2,_3,...) _3
int main(int argc, char *argv[]) {
printf("()=%i\n",ARGS_COUNT());
printf("(1,2,3)=%i\n",ARGS_COUNT(1,2,3));
printf("(,)=%i\n",ARGS_COUNT(,));
printf("(5)=%i\n",ARGS_COUNT(5));
printf("(6,)=%i\n",ARGS_COUNT(6,));
return 0;
}