How to call 'printf' using libffi?

Anthony Green green@moxielogic.com
Fri Mar 19 11:33:29 GMT 2021


On Fri, Mar 19, 2021 at 7:26 AM Jarkko Hietaniemi <jhi@iki.fi> wrote:

> >>    /* 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,
> >
>
> Yeah, it's a mess, e.g.
>
>
> https://www.quora.com/How-are-varargs-typically-implemented-in-C-under-the-hood
>
>

Libffi has you covered with ffi_prep_cif_var()

AG


More information about the Libffi-discuss mailing list