By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Wrapping functions with variable argument list

P: 1
Hi All,
As part of my job, I need to wrap around an existing library of functions.
Some functions have the prototype
void foo(int keyword, ...)
{
}
where ... could be a list of any size, of mixed parameter type, terminated by int 0
e.g.
foo(1 /*keyword*/, "Hello", 3.4, "World", 0 /*list terminator*/);

I need to create a wrapper
void bar(int keyword, ...) //must have same signature as foo
{
//some processing
foo(keyword, ...); // how do I pass va_args list without actually using va_args

}

Using va_args semantics is not an option because foo is already deployed in other applications and its prototype cannot change.
How do I accomplish this?
I understand that I probably need to use assembly to play with the stack arguments, but I don't know how.

Thanks
Jun 20 '07 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
I need to create a wrapper
void bar(int keyword, ...) //must have same signature as foo
{
//some processing
foo(keyword, ...); // how do I pass va_args list without actually using va_args

}
I believe your wrapper has to use va_args to get the arguments used on the bar to call foo(keyword, ...). That may require that you limit the number of arguments.
Jun 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.