Pointers to variables in the current address space may be looked up
dynamically using dynamic-pointer.
Return a “wrapped pointer” for the symbol name in the shared object referred to by dobj. The returned pointer points to a C object.
Regardless whether your C compiler prepends an underscore ‘_’ to the global names in a program, you should not include this underscore in name since it will be added automatically when necessary.
For example, currently Guile has a variable, scm_numptob, as part
of its API. It is declared as a C long. So, to create a handle
pointing to that foreign value, we do:
(use-modules (system foreign))
(define numptob (dynamic-pointer "scm_numptob" (dynamic-link)))
numptob
⇒ #<pointer 0x7fb35b1b4688>
(The next section discusses ways to dereference pointers.)
A value returned by dynamic-pointer is a Scheme wrapper for a C
pointer.
Return the numerical value of pointer.
(pointer-address numptob) ⇒ 139984413364296 ; YMMV