One can access the contents of ...
inside a function using stdarg.h
:
void fn(int nargs, ...){
va_list args; va_start(args,nargs);
i64 arg0 = va_arg(args,i64);
va_end(args);
}
The only way I know of using __VA_ARGS__
is to pass it to another macro or, eventually, a function. Eg.
#define __fn(...) fn(number_of_args(__VA_ARGS__), __VA_ARGS__)
but I wonder if it's possible to "unpack" the values of __VA_ARGS__
within a macro itself. Something like va_start()
, va_arg()
, and va_end()
, but for macros.