How to call 'printf' using libffi?

Anthony Green green@moxielogic.com
Fri Mar 19 11:01:35 GMT 2021


On Fri, Mar 19, 2021 at 6:13 AM Andrew Haley via Libffi-discuss <
libffi-discuss@sourceware.org> wrote:

> On 3/18/21 3:25 PM, Anthony Green wrote:
> >   arg_types[0] = &ffi_type_pointer;
> >   arg_types[1] = &ffi_type_double;
> >   arg_types[2] = &ffi_type_sint;
> >   arg_types[3] = NULL;
> >
> >   /* This printf call is variadic */
> >   ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 3, &ffi_type_sint,
> arg_types);
>
> Surely that only works if a varargs call uses the same ABI as a normal
> call. They don't always,
>

I'm using the '_var' variant of ffi_prep_cif that takes this into account.

AG


More information about the Libffi-discuss mailing list