c2ffi handling va_list

Madhu enometh at meer.net
Thu Jul 16 15:08:12 UTC 2020


*  Martin Simmons <martin at lispworks.com> <202007161039.06GAdKKb016862 at higson.cam.lispworks.com>
Wrote on Thu, 16 Jul 2020 11:39:20 +0100
>>>>>> On Thu, 16 Jul 2020 11:42:17 +0530 (IST), Madhu  said:
>> In order to "treat va_list as any other argument" I tried adding an
>> opaque (cffi:defcstruct (:builtin-va-list :size 192)) -- 192 being
>> sizeof(va_list) with x86_64-pc-linux-gnu-gcc -- having
>> %json-type-to-cffi-type return that when it comes across a cffi tag
>> "__builtin_va_list". cffi/c2ffi can generate defcfns for functions
>> which use va_list in the signature.  I think the user would still be
>> hardpressed to find a way to use them.
>
> I think this defcstruct is wrong on x86_64-pc-linux-gnu-gcc for two reasons:
>
> 1. sizeof(va_list) is 24 bytes for me.
>
> 2. It is an array, not a struct, so it is passed as a pointer.
>
> I.e.
>
> int bar(va_list z)
> {
>   return sizeof(z);
> }
>
> will return the same as sizeof(void *).

mea culpa on both counts. i see it is defined be an array type so it
is always handled as a pointer.




More information about the cffi-devel mailing list