Wrap C function which takes variable lengthed parameters?

Courageous jkraska at san.rr.com
Fri Dec 14 02:52:03 EST 2001


>> Yes.  Varargs can be used to make a va_list and pass that into another
>> function.  Use of varargs and va_list are ANSI compliant.
>
>But you can't contstruct a va_list and pass it to a _vararg_ function;
>or at least it's not standard, portable, etc. See eg.
>
>  http://www.eskimo.com/~scs/C-faq/varargs/invvarargs.19920714.html
>
>Unless I missed something, I think this is what the OP wanted.

I believe you are correct. If this absolutely _must_ be done, there's
probably a way to munge the stack correctly to get it to work on a
per-platform basis. I'm not sure, but I believe that most of the time,
varargs are just additional stack pushes or some such. But counting
on that, especially in today's age of compiler optimizations and so
forth, could lead to some pretty nasty outcomes.

Speaking of the problem, it might help the O.P. to post some more
details of the larger problem to see if there is an additional way
of achieving what is desired. He might also consider posting to
comp.lang.c and not posting anything to do with Python. Python
neither helps nor hinders, it's just its own layer in C.

C//




More information about the Python-list mailing list