[Openmcl-devel] foreign vars

Gary Byers gb at clozure.com
Thu Aug 19 05:40:57 PDT 2004

On Thu, 19 Aug 2004, Marco Baringer wrote:

> this must be documentated somewhere, but i can't seem to figure out
> how to get the value of a foreign var. i know the functions and
> constants are available, but i very simply don't know what to type to
> get the value of a variable.
> --
> -Marco

If you're using 0.14.2 or later (and the interface database that came
with that version, or interfaces that you generated yourself with 0.14.2
or later) and the foreign variable in question is defined in those interfacs,
you can use the #? reader macro.

If you're using 0.14.2 or later but the other conditions don't hold,
you can define the foreign variable yourself (describe its foreign
type and put that information where #? can find it.)  There isn't a
DEFINE-FOREIGN-VARIABLE; someone asked about this a few weeks ago,
and I think that my response (should be in the list archive) was

If you're using an older version (or want to live dangerously, or
are just curious), you can use CCL:FOREIGN-SYMBOL-ADDRESS to obtain
the address of a foreign variable, given a string which names that

? (ccl:foreign-symbol-address "_errno") ; a bad example, probably

The value that that returns (if non-NIL) is the address of the variable
(like &errno in C); if "errno" was still a global variable of type "int"
(which it may not be, because of threads ...) you could get its value

? (pref (ccl:foreign-symbol-address "_errno") :int)

More information about the Openmcl-devel mailing list