How to call 'printf' using libffi?

Jarkko Hietaniemi jhi@iki.fi
Fri Mar 19 11:26:48 GMT 2021


Andrew Haley via Libffi-discuss 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,
> 

Yeah, it's a mess, e.g.

https://www.quora.com/How-are-varargs-typically-implemented-in-C-under-the-hood



More information about the Libffi-discuss mailing list