On Dec 16, 2005, at 10:54 AM, Roberto Bagnara wrote:
I am sure I am missing something, but I don't know what.
Below the signature I report everything that is necessary
to reproduce my observations. In short, PL_unify_pointer()
does not seem to work as expected: in the C code I unify
a term with a pointer pointing at X, and in Prolog I get
a different pointer. Notice that X has been obtained, in
the original code, by C++'s operator new(). But it doesn't
even look like a truncation problem, since in different runs
of SWI-Prolog I get different values.
What am I missing?
SWI-Prolog does it best it get most pointers into cheap short
integers. For doing that it mangles the pointer in a machine
dependent way. It only guarantees that PL_unify_pointer()
and PL_get_pointer() are each others reverse. If you want
the plain pointer, simply use PL_unify_integer(). In general
Prolog shouldn't want to know though.
--- Jan
|