users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: another problem interfacing prolog and C


From: Erick Alphonse
Subject: Re: another problem interfacing prolog and C
Date: Sat, 18 Dec 2004 20:22:33 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913

Hello Daniel,

Daniel Diaz wrote:
the problem comes from the fact you invoke Prolog from your call_c/2
 foreign code. This one uses 2 arguments (a and _L) which are stored
into an array (accessible via macros X(0) and X(1)). But since
write/1 itself is partly written in Prolog it also uses X(...)
variables. So, the clean way to fix it would be to inform the
compiler a foreign code calls Prolog (and thus the compiler would
emit code to save/restore the X(...) vars used).

For the moment you can do it by hand (okay it is a bit dirty) as
follows:

Thanks a lot for your help and the explanations!

I have another question. In the documentation, you explain another way to output results:

When +term is specified the term passed to the function is the
original Prolog term. It can be read and/or unified. It is also the
case when term is specified without any mode symbol.

and use this in one of your examples.

Do we need to save/restore the X() vars in that case too, or only when we pass pointers to the C function (like -term or +string).

> So, the clean way to fix it would be to inform the
> compiler a foreign code calls Prolog (and thus the compiler would
> emit code to save/restore the X(...) vars used).

If you want to talk about this issue further, I would be very interested to do so with you.

Thanks again,
Best regards,
Erick.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]