How to count the number of arguments passed to a function that accepts a variable number of arguments?

前端 未结 10 2145
旧时难觅i
旧时难觅i 2020-12-01 05:18

How to count the no of arguments passed to the function in following program:

#include
#include
void varfun(int i, ...);
int m         


        
10条回答
  •  半阙折子戏
    2020-12-01 05:39

    If you have a C99 compliant compiler (including the preprocessor) you can circumvent this problem by declaring a macro that computes the number of arguments for you. Doing this yourself is a bit tricky, you may use P99_VA_ARGS from the P99 macro package to achieve this.

提交回复
热议问题