Module blog::daily_rfcs::ffi::_2137_variadic
source · [−]Expand description
Support defining C-compatible variadic functions in Rust.
Note
Variadic fucntion declaration:
pub unsafe extern "C" fn foo(arg: T, arg2: T2, args: ...);
- The use of
...
as the type ofargs
at the end of the argument list declares the functionfoo
as variadic function. args: ...
must apears as the last argument of the function, and there must be at least one argument before it.- The function must be
extern "C"
andunsafe
. - The real type of
args
iscore::intrinsics::VaList<'a>
, the lifetme'a
prevents the arguments from outliving the variadic function.