This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
RE: Variadic functions and libffi
>> that is just like ffi_prep_cif but also takes a 'nnamedargs' to say
>> the number of fixed args (and hence which arg is the 1st variadic).
>
> I don't think this is such a great design, because you'd be doing the
> calculation about where to put the args at the time of the call. IMO
> it makes more sense to do as much precomputation as possible, by
> calling ffi_prep_cif_variadic with the actual number of fixed args and
> the actual number of varargs you intend to pass. In almost all usages
> of libffi you really will know the number of arguments to be passed
> when preparing the CIF. If you can precompute all this stuff you can
> even use a JIT to generate code for the call.
The prototype David and I discussed has the form:
ffi_status ffi_prep_cif_variadic(ffi_cif *cif, ffi_abi abi, unsigned int
nargs, unsigned int nnamedargs, ffi_type *rtype, ffi_type **atypes);
Which makes available the total number of arguments, the number of named
arguments and hence the number of anonymous arguments up front.
Marcus