in reply to C Functions with variable argument list in perlxs

That is not a simple thing to do.

If your function expects a variable length list of arguments of different types, the best approach would probably be to replace it by another function accepting a list of SVs, implemented using lower level functions.

Another option would be to implement the formating part in Perl, for instance:

sub FWriteF { my $file = shift; my $fmt = shift; my $text = sprintf($fmt, @_); _FRwriteF($file, $text); # calls C function as # FWriteF($file, "%s", $text); }

If your function expects a variable list of arguments of the same type, sometimes it is acceptable to set a limit on the number or arguments so you can use something like this:

int FWriteF(file, fmt, a0=0, a1=0, a2=0, a3=0,...., a10=0) FILE *file, const char *fmt int a0 int a1 ... int a10 CODE: switch (items - 2) { case 0: RETVAL = FWriteF(file, fmt); break; case 1: RETVAL = FWriteF(file, fmt, a1); break; case 0: RETVAL = FWriteF(file, fmt, a1, a2); break; ... case 10: RETVAL = FWriteF(file, fmt, a1, a2, a3, ..., a10); break; } OUTPUT: RETVAL
If I recall correctly, that's how SWIG does, for instance.