FFI_PREP_CIF_VAR(3)
π ffi_prep_cif_var(3) β bestie's guide to variadic call prep π
okay so you're in section 3 of the manual (the library-functions girlies), and this page is all about ffi_prep_cif_var β the function you reach for when the function you're calling is a variadic one. yes, like printf-core. we're getting the ffi_cif struct ready to be handed off to ffi_call. let's GO β¨
β¨ NAME β¨
ffi_prep_cif_var β prepares a ffi_cif structure for use with ffi_call when you're calling variadic functions. that's the whole job. she's a specialist π
πΈ SYNOPSIS πΈ
#include <ffi.h>
ffi_status
ffi_prep_cif_var(ffi_cif *cif, ffi_abi abi, unsigned int nfixedargs,
unsigned int ntotalargs, ffi_type *rtype, ffi_type **atypes);
π¦ DESCRIPTION π¦
so like, the ffi_prep_cif_var function gets a ffi_cif structure ready to go for use with ffi_call, specifically for variadic functions. think of it as doing her hair and makeup before the big performance, no cap.
here's the cast of characters, bestie:
abiβ tells her which set of calling conventions to use. the vibe check of the platform, basically.atypesβ an array ofntotalargspointers toffi_typestructs, and each one describes the data type, size and alignment of one argument. all of them. every single one. πrtypeβ points to anffi_typethat describes the data type, size and alignment of the return value.nfixedargsβ must contain the number of fixed (i.e. non-variadic) arguments. this is not optional, this is the assignment.
π«Ά lowkey important: if you're calling a function that is not variadic, you do NOT use this one β you use ffi_prep_cif instead. wrong function, wrong energy, don't do it.
π RETURN VALUES π
FFI_OKβ returned upon successful completion. slay, we ate, periodt β¨FFI_BAD_TYPEDEFβ returned ifcifisNULL, or ifatypesorrtypeis malformed. she said "this typedef is giving nothing" πFFI_BAD_ABIβ returned ifabidoesn't refer to a valid ABI.
and psa bestie: the available ABIs are defined in <ffitarget.h>. go look there, iykyk π
π SEE ALSO π
that's the whole page, babe π this one came from the ffi_prep_cif_var(3) manual page, dated January 25, 2011 β yeah she's an elder but she still eats. go forth and prep those variadic calls, main character ππ
π¦ where this page comes from
- alpine 3.22: libffi-doc 3.4.8-r0 Β· MIT
- alpine 3.23: libffi-doc 3.5.2-r0 Β· MIT
- alpine 3.24: libffi-doc 3.5.2-r1 Β· MIT
- arch rolling: libffi 3.8.0-1 Β· MIT
- centos-stream 10: libffi-devel 3.4.4-10.el10 Β· MIT
- centos-stream 9: libffi-devel 3.4.2-8.el9 Β· MIT
- centos-stream 9: libffi-devel 3.4.2-8.el9 Β· MIT
- debian bookworm: libffi-dev 3.4.4-1
- debian trixie: libffi-dev 3.4.8-2
- fedora 43: libffi-devel 3.5.1-2.fc43 Β· MIT AND CC-PDDC AND (GPL-3.0-or-later WITH Texinfo-exception)
- fedora 43: libffi-devel 3.5.1-2.fc43 Β· MIT AND CC-PDDC AND (GPL-3.0-or-later WITH Texinfo-exception)
- fedora 43: libffi-devel 3.5.2-1.fc43 Β· MIT AND CC-PDDC AND (GPL-3.0-or-later WITH Texinfo-exception)
- fedora 43: libffi-devel 3.5.2-1.fc43 Β· MIT AND CC-PDDC AND (GPL-3.0-or-later WITH Texinfo-exception)
- fedora 44: libffi-devel 3.5.2-2.fc44 Β· MIT AND CC-PDDC AND (GPL-3.0-or-later WITH Texinfo-exception)
- fedora 44: libffi-devel 3.5.2-2.fc44 Β· MIT AND CC-PDDC AND (GPL-3.0-or-later WITH Texinfo-exception)
- nixos 26.05: ruby3.3-ffi 1.17.2
- nixos 26.05: ruby3.4-ffi 1.17.2
- nixos 26.05: ruby4.0-ffi 1.17.2
- nixpkgs unstable: libffi 40
- nixpkgs unstable: ruby3.4-ffi 1.17.2
- nixpkgs unstable: ruby4.0-ffi 1.17.2
- opensuse-leap 16.0: libffi-devel 3.4.6-160000.2.2 Β· MIT
- opensuse-leap 16.0: libffi-devel 3.4.6-160000.2.2 Β· MIT
- opensuse-leap 16.0: libffi-devel 3.4.6-160000.2.2 Β· MIT
- opensuse-leap 16.0: libffi-devel 3.4.6-160000.2.2 Β· MIT
- ubuntu jammy: libffi-dev 3.4.2-4
- ubuntu noble: libffi-dev 3.4.6-1build1
- ubuntu questing: libffi-dev 3.5.2-1build1
- ubuntu resolute: libffi-dev 3.5.2-4
- ubuntu stonking: libffi-dev 3.8.0-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms