Wrap C function which takes variable lengthed parameters?

Courageous jkraska at san.rr.com
Sat Dec 15 12:22:48 EST 2001


>This is a C problem but this is also a Python problem.
>There are no need to wrap a C function for C program.
>It is a problem caused by limitation of C language, though.

That's what I meant. Python can't do it because C can't
do it, and Python is coded in C. A C programmer faced with
the same problem, say an array of values and a variadic
function, would be unable to continue as well.

Faced with a similar problem once, I ended up getting a
rendition of the printf libraries done that made public
its internal functions so that the varargs array could
be prepped explicitly. It worked well, and I still use
it today.

I wrote a really cool function that works like this:

char* str = NULL

remprint (&str, <format-string>, ...);

The function detects the allocation length of the format
string and allocates the memory for you. No more overflowing
string buffers on format expansions.

Cool, eh?

C//




More information about the Python-list mailing list