Package: cffi

Function foreign-symbol-pointer

Lambda List

foreign-symbol-pointer (name &key library)


foreign-name -- A string.
pointer -- A foreign pointer, or nil.
library -- A Lisp symbol or an instance of foreign-library.


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. (e.g. 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.


  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