appending last argument to (wrap(ed)) variadic function call
Alexandre François Garreau
galex-713@galex-713.eu
Mon Feb 24 03:09:00 GMT 2020
I want to wrap a call to a variadic function (which have both a really
variadic version, and one taking a va_list as argument), and let its last
argument be fixed by this wrapper (accordingly modifying the fixed argument
that specify about the variable arguments and their types)… how can I do
that?
That last argument happens to need to be declared (in a local scope, in my
case), so I can do it with a macro, unless I resort to GNU compound
statements (“({char * trailing[2]; ...; ret_value;})”).
I want to do something like:
#define escanf(argc, format, ...) ({ char trailing[2], *format =
astrcat(format, "%1s"); int ret = escanf(format, __VA_ARGS__, &trailing);
free(format); ret != argc; })
But in a function… possibly itself variadic, so working with a va_list.
More information about the Libc-help
mailing list