all In glusterfs's functions, there is one as follows NOTES: the whole define in stack.h
//libglusterfs/src/glusterfs/stack.h
#define STACK_WIND(frame, rfn, obj, fn, params...) \
STACK_WIND_COMMON(frame, rfn, 0, NULL, obj, fn, params)
#define STACK_WIND_COMMON(frame, rfn, has_cookie, cky, obj, fn, params...) \
do { \
... \
next_xl_fn(_new, obj, params); \
THIS = old_THIS; \
} while (0)
I did not google search anything about explaining such declaring methods, any idea will be appreciated?
CodePudding user response:
params...
as part of function-like macro is a GNU extension before C standardized ellipsis as part of arguments of function-like macros.
See https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html#Variadic-Macros
Nowadays, prefer __VA_ARGS__
.
In C function declaration 'params, ...)' equal to 'params...)'?
No, they are not equal in function-like macros. The first one needs to use __VA_ARGS__
to reference variadic arguments and use __VA_OPT__
or ##__VA_ARGS__
to remove leading comma. In the params...
then params
is straight up replaced by all the arguments including commas.
Doing just ellipsis , ...)
and using __VA_ARGS__
would be equal to , params...)
and using params
.
In normal functions params...
as part of parameter-list is just invalid.