There is a function:
void some_function(int id,...);
question: is there a way to wrap this function? It means to get something like this:
void wrapped_some_function(int id,...)
{
//do smth
some_function(id,...);
}
With gcc, __builtin_apply_args
and __builtin_apply
, documented here, can do it.
For standard C, there's no way (what other answers suggest can work, but it isn't 100% what you ask for).
But if there's a variation of some_function
that gets va_list
(like vprintf
is a variation of printf
), you can use it.
Since this is also tagged C++: C++11 ftw.
#include <utility> // forward
template<class... Args>
void wrapped_some_function(int id, Args&&... args)
{
//do smth
some_function(id, std::forward<Args>(args)...);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With