All Manuals > Foreign Language Interface User Guide and Reference Manual > 7 Function, Macro and Variable Reference

make-pointer Function

Summary

Creates a pointer to a specified address.

Package

fli

Signature

make-pointer &key address type pointer-type symbol-name functionp module encoding => pointer

Arguments
address
The address pointed to by the pointer to be created.
type
The type of the object pointed to by the pointer to be created.
pointer-type
The type of the pointer to be made.
symbol-name
A string or a symbol.
functionp
A boolean.
module
A symbol or string naming a module, or nil.
encoding
One of :source, :object, :lisp or :dbcs.
Values
pointer
A pointer to address.
Description

The function make-pointer creates a pointer of a specified type pointing to a given address address, or optionally to a function or foreign callable.

symbol-name is either a string containing the name of a foreign symbol defined in a DLL, or a string or symbol naming a foreign callable defined by define-foreign-callable.

Either address or symbol-name must be supplied, otherwise make-pointer signals an error.

Note that in many cases, especially when :symbol-name is used with a symbol defined by define-foreign-callable, foreign-function-pointer would be better than using make-pointer with :symbol-name.

If type is supplied, then it is used as the FLI type that pointer points to. Alternatively, if pointer-type is supplied, then it must be a FLI pointer type and it is used as the pointer type of pointer. An error is signalled if both type and pointer-type are supplied.

If type or pointer-type are not supplied, then functionp can be used. If functionp is t, then pointer is a pointer to type :function. This is the default value. If functionp is nil, then pointer is a pointer to type :void.

encoding controls how symbol-name is processed. The values are interpreted like the encode argument of define-foreign-callable. The default value of encoding is :source if symbol-name is a string and :lisp if symbol-name is a symbol.

In the case of a pointer to a foreign callable or foreign function, module can be supplied to ensure that the pointer points to the function in the correct DLL if there are other DLLs containing functions with the same name. module is processed as by define-foreign-function.

Examples

In the following example a module is defined, and the variable setpoint is set equal to a pointer to a function in the module.

(fli:register-module :user-dll :real-name "user32")
(setq setpoint
      (fli:make-pointer :symbol-name "SetCursorPos"
                        :module :user-dll)
See also

3 FLI Pointers
4.1 Foreign callables and foreign functions
copy-pointer
define-foreign-callable
foreign-function-pointer
register-module
with-coerced-pointer


Foreign Language Interface User Guide and Reference Manual - 01 Dec 2021 19:34:58