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


foreign-symbol-pointer

foreign-symbol-pointer

Syntax

Function: foreign-symbol-pointer foreign-name &key library ⇒ pointer

Arguments and Values

foreign-name

A string.

pointer

A foreign pointer, or nil.

library

A Lisp symbol or an instance of foreign-library.

Description

The function foreign-symbol-pointer will return a foreign pointer corresponding to the foreign symbol denoted by the string foreign-name. If a foreign symbol named foreign-name doesn’t exist, nil is returned.

ABI name manglings will be performed on foreign-name by foreign-symbol-pointer if necessary. (eg: adding a leading underscore on darwin/ppc)

library should name a foreign library as defined by define-foreign-library, :default (which is the default) or an instance of foreign-library as returned by load-foreign-library.

Important note: do not keep these pointers across saved Lisp cores as the foreign-library may move across sessions.

Examples

  CFFI> (foreign-symbol-pointer "errno")
  ⇒ #<A Mac Pointer #xA0008130>
  CFFI> (foreign-symbol-pointer "strerror")
  ⇒ #<A Mac Pointer #x9002D0F8>
  CFFI> (foreign-funcall-pointer * () :int (mem-ref ** :int) :string)
  ⇒ "No such file or directory"
   
  CFFI> (foreign-symbol-pointer "inexistent symbol")
  ⇒ NIL

See Also

defcvar