FFI_PREP_CIF(3)
π NAME π
ffi_prep_cif β bestie, this is the one that gets your ffi_cif struct all dolled up and ready for ffi_call β¨
πΈ SYNOPSIS πΈ
#include <ffi.h>
ffi_status
ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs,
ffi_type *rtype, ffi_type **atypes);
π¦ DESCRIPTION π¦
okay so picture this: you wanna call some function through FFI but nothing works until the ffi_cif is prepped, and ffi_prep_cif is literally the glow-up montage π
It sets up a ffi_cif structure so it's ready to be handed off to ffi_call. main character energy fr.
abi is where you say which set of calling conventions you wanna use β like picking your outfit for the day, but for how arguments get passed π₯
atypes</purpose> is an array of nargs pointers to ffi_type structs, and each one describes the data type, the size, and the alignment of one single argument. one struct per arg, no skipping, no shortcuts π
rtype points to an ffi_type that describes the data type, size and alignment of the return value β yes bestie, the thing that comes back to you π
β οΈ not me about to forget the important one: if you're trying to call a variadic function,ffi_prep_cifis NOT the girl for the job. you have to useffi_prep_cif_varinstead. periodt. no exceptions π
π RETURN VALUES π
FFI_OKβ slay, it worked, we ate πFFI_BAD_TYPEDEFβ returned whencifisNULL, or whenatypesorrtypeis malformed π something in your type situation is giving broken.FFI_BAD_ABIβ returned whenabidoes not refer to a valid ABI π
and btw, the ABIs that are actually available to you are defined in <ffitarget.h> β that's where you go to see what you're working with, iykyk π
π SEE ALSO π
and that's the whole vibe!! this page was born on February 15, 2008 and lives under the ffi_prep_cif(3) manual entry β still iconic, still relevant, still prepping cifs after all these years π«Άπ§π
π¦ 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