I have a use case where i need the count of arguments passed to variadic macro in c. I tried using the following code:
#define COUNT_ARGS(...) COUNT_ARGS_(,##__VA_ARGS__,9,8,7,6,5,4,3,2,1,0)
#define COUNT_ARGS_(z,a,b,c,d,e,f,g,h,i,cnt,...) cnt
But this has a serious issue, if user passes say 11 arguments to this maro the count is returned as value of 11th argument.
Is there any other way i can get the count of arguments passed.