Re: [GD-General] variadic functions
Brought to you by:
vexxed72
From: Andras B. <bn...@ma...> - 2003-11-27 21:24:00
|
Brett, What do you mean by using a generalized solution? In the case of a vararg function, you have to describe the parameters somehow! And the easiest way to do it is via a string: for example "iicfds" would mean: (int, int, char, float, double, char*). Of course this means that you have to prepare your function to be able to interpret this format string, and act appropriately, but I think this should not be a problem as there is no point in writing a vararg function that can't handle different sets of parameters... In case you only have a couple of variants, then it might be more efficient to make different versions of the function to handle each case, and bind them separately. And to answer your last question: Yes, simply pushing the values and calling the func should do the job. But don't forget to pop the values from the stack after the func returned, as it's your (the caller's) job to clean-up the stack!!! Cheers, Andras Thursday, November 27, 2003, 11:02:46 AM, Brett Bibby wrote: > Andras, > Thanks for the post. Pretty much my conclusion too. But I'm not using > this for printf so I need a generalized solution, although I could > theoretically create bindings for every possible case (which is normal > for scripting engine binding anyway). Since the callee doesn't know how > many parameters there are, it seems I just need to push the values to > the stack in assembly code and then call the variadic function. Does > that sound right? > Brett |