[Pyrex] how to declare and use variable length argument lists
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Feb 23 03:43:42 CET 2006
Victor Ng wrote:
> On 2/3/05, *Parzival Herzog* < parzp at shaw.ca <mailto:parzp at shaw.ca>> wrote:
>
> Pyrex accepts C variable length argument list syntax, e.g .
>
> cdef object _tuple(char *fmt, ...):
> return ()
>
> but what can I tell pyrex to cover the macros va_list, va_start,
> va_end, and va_arg from stdarg.h?
Pyrex currently supports the varargs declaration syntax so
that you can call externally-defined varargs functions from
Pyrex code, but there isn't yet any support for writing
functions in Pyrex that accept varargs. That's one of the
things on my ever-growing todo list.
You can probably get most of the way with something like
cdef extern from "stdarg.h":
ctypedef void *va_list
void va_start(va_list ap, void *last)
void va_end(va_list ap)
Then you would probably have to deal with the various
argument types you want to use individually, e.g.
cdef extern from "myargs.h":
int va_int(va_list ap)
char *va_charptr(va_list ap)
etc, where myargs.h looks like
#define va_int(ap) va_arg(ap, int)
#define va_charptr(ap) va_arg(ap, char *)
Warning: I haven't tested any of this. Use it at your
own risk.
--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | Carpe post meridiam! |
Christchurch, New Zealand | (I'm not a morning person.) |
greg.ewing at canterbury.ac.nz +--------------------------------------+
More information about the Pyrex
mailing list