|
P99
|
Helper macro to declare a variable length parameter list. Inside the declared function X will of Wrap your function into a macro that uses P99_LENGTH_VA_ARG. If used through that macro, the correct value for X will always be provided at compile time. Declare such a function as this: unsigned P99_FSYMB(toto)(unsigned a, P99_VA_ARGS(number)); #define toto(A, ...) P99_FSYMB(toto)(A, P99_LENGTH_VA_ARG(__VA_ARGS__)) In the definition of the function you then may use the unsigned P99_FSYMB(toto)(unsigned a, P99_VA_ARGS(number)) { unsigned ret = 0; va_list ap; va_start(ap, number); for (size_t i = 0; i < number; ++i) { ret += va_arg(ap, unsigned); } va_end(ap); return ret % a; } In this toy example unsigned magic = toto(3, 1, 3, 5, 7);
which will result in converting 1, 3, 5, 7 (the variable arguments) to
Definition at line 203 of file p99_args.h. |
1.7.6.1