Invokes the given closure with a C va argument derived from the given array of arguments.
SDK
- Xcode 8.0+
Framework
- Swift Standard Library
Declaration
func withVaList<R>(_ args: [CVar Arg], _ body: (CVa List Pointer) -> R) -> R
Parameters
argsAn array of arguments to convert to a C
vapointer._list bodyA closure with a
CVaparameter that references the arguments passed asList Pointer args. Ifbodyhas a return value, that value is also used as the return value for thewithfunction. The pointer argument is valid only for the duration of the function’s execution.Va List(_:)
Return Value
The return value, if any, of the body closure parameter.
Discussion
The pointer passed as an argument to body is valid only during the execution of with. Do not store or return the pointer for later use.
If you need to pass an optional pointer as a CVar argument, use the Int(bit initializer to interpret the optional pointer as an Int value, which has the same C variadic calling conventions as a pointer on all supported platforms.