[Pyrex] How to handle C functions with variable number of args
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Nov 20 01:18:28 CET 2008
Dog Walker wrote:
> cdef extern int xosd_display(xosd * osd, int line, xosd_command
> command, ...) except -1
>
> def displaytext(self, line, command, *arg):
> #and then call the xosd_display function declared above
There is no support in Pyrex for passing on a *args
argument to a C varargs function. Although the concepts
are vaguely similar, they're really very different things.
You'll have to iterate over the *args, inspect their
types and make an appropriate series of single-arg calls
to get the effect you want.
> Where is handling C varargs in Pyrex documented, btw?
Apparently it's not documented anywhere. :-( But there's
not really much to say -- you can declare an external
function as taking varargs, and you can call it with some
number of arguments fixed at the point of call. That's
about all.
--
Greg
More information about the Pyrex
mailing list