Wrap C function which takes variable lengthed parameters?
Greg Ewing
greg at cosc.canterbury.ac.nz
Sun Dec 16 23:37:17 EST 2001
Just van Rossum wrote:
>
> But you can't contstruct a va_list and pass it to a _vararg_ function;
You can construct a wrapper that will handle up to
some maximum number of parameters, by exploiting the
fact that a varargs function doesn't care if you pass
it more parameters than it's expecting -- it will just
ignore the rest. So, you can do e.g.
whatever_argtype *a[10];
/* unpack the Python args into a and NULL terminate if needed */
whatever_function(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7],
a[8], a[9]);
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list