Menu

Reference / Ffi

Variadic

finalclass
final class Variadic

Marks a binding as a C variadic function (ret f(a, b, ...)).

$fixed is the number of named parameters before the ...; the remaining bound parameters are the variadic arguments. The wrapper is then emitted with a variadic call type so the target's ABI places the extra arguments correctly (on Darwin arm64 they go on the stack). $fixed must lie between 0 and the binding's arity, otherwise compilation fails. Both #[Variadic(2)] and #[Variadic(fixed: 2)] are accepted.

#[Library('c'), Symbol('fcntl'), Variadic(2), CType('int')]
function fcntl(#[CType('int')] int $fd, #[CType('int')] int $cmd,
               #[CType('int')] int $arg): int { return -1; }

See also: Symbol, CType

Methods

__construct()Create the attribute.

__construct()#source

function __construct(public int $fixed)

Create the attribute.

Parameters

$fixed int
number of named parameters before the ...

View source