It is completely valid C99 code. It has one drawback, though - you cannot invoke the macro SUM() without params, but GCC has a solution to it - http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
So in case of GCC you need to define macros like this and it will work even with empty parameter list
#define NUMARGS(...) (sizeof((int[]){0, ##__VA_ARGS__})/sizeof(int)-1) #define SUM(...) sum(NUMARGS(__VA_ARGS__), ##__VA_ARGS__)use this GNU extension, Just remember - it only works with GNU compiler.
#define macro(format, arguments...) fprintf(stderr, format, ##arguments)The ## token in combination with __VA_ARGS__ is a gcc extension that's not part of ISO C99.
转载于:https://www.cnblogs.com/shangdawei/archive/2013/05/28/3102927.html
相关资源:数据结构—成绩单生成器