Next: , Previous: , Up: Functions   [Contents][Index]


foreign-funcall-varargs

foreign-funcall-varargs

Syntax

Macro: foreign-funcall-varargs name-and-options (fixed-arguments) &rest arguments ⇒ return-value

fixed-arguments ::= { arg-type arg }* [return-type]
arguments ::= { arg-type arg }* [return-type]
name-and-options ::= name | (name &key library convention)

Arguments and Values

name

A Lisp string.

arg-type

A foreign type.

arg

An argument of type arg-type.

return-type

A foreign type, :void by default.

return-value

A lisp object.

library

A lisp symbol; not evaluated.

convention

One of :cdecl (default) or :stdcall.

Description

The foreign-funcall-varargs macro is the main primitive for calling foreign variadic functions. It behaves similarily to foreign-funcall except fixed-arguments are distinguished from the remaining arguments.

Examples

  CFFI> (with-foreign-pointer-as-string (s 100)
          (setf (mem-ref s :char) 0)
          (foreign-funcall-varargs
           "sprintf" (:pointer s :string) "%.2f")
           :double (coerce pi 'double-float) :int))
  ⇒ 3.14