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


with-foreign-string

with-foreign-string, with-foreign-strings

Syntax

Macro: with-foreign-string (var-or-vars string &rest args) &body body
Macro: with-foreign-strings (bindings) &body body

var-or-vars ::= var | (var &optional octet-size-var)
bindings ::= {(var-or-vars string &rest args)}*

Arguments and Values

var, byte-size-var

A symbol.

string

A Lisp string.

body

A list of forms to be executed.

Description

The with-foreign-string macro will bind var to a newly allocated foreign string containing string. Args is passed to the underlying foreign-string-alloc call.

If octet-size-var is provided, it will be bound the length of foreign string in octets including the null terminator.

Examples

  CFFI> (with-foreign-string (foo "12345")
          (foreign-funcall "strlen" :pointer foo :int))
  ⇒ 5

See Also

foreign-string-alloc
with-foreign-pointer-as-string