Wrapping C functions with variable prameters
- Posted by ghaberek (admin) Jun 25, 2012
- 1379 views
I need some help from the C gurus around here. I'm a bit stumped on how to wrap a few functions I've come across.
I'm trying to wrap newt and it it seems to use a variable number of parameters on a few of its functions, like so:
/* last item is NEWT_ARG_LAST for all of these */ int newtCheckboxTreeAddItem(newtComponent co, const char * text, const void * data, int flags, int index, ...);
And here's what I started with...
x_newtCheckboxTreeAddItem = define_c_func( libnewt, "newtCheckboxTreeAddItem", {C_POINTER,C_POINTER,C_POINTER,C_INT,C_INT}, C_INT )
I was thinking that I could just fill out the parameters with an inordinate series of C_INT,C_INT until the cows come home, but I'm not sure what the maximum number of parameters is. I also thought that I could re-declare the function on each call for that particular number of parameters (probably with some smart caching involved). Any ideas?
-Greg