[Top][All Lists]

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

another problem interfacing prolog and C

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


Still playing with the interface, I would like to call C from prolog and then from this C function call prolog back. Unfortunately, I can't get it working.

:- initialization(top).

:- foreign(call_c(+term,-term)).

top :-

% examp_c.c
#include <string.h>
#include "gprolog.h"

call_c(PlTerm In,PlTerm* Out)

  *Out = Mk_Atom(atom_nil);

  return PL_SUCCESS;

And I get :
874# gplc examp_c.c
875# ./examp
warning: /home/alphonse/tmp/bug-prolog/ user directive failed
GNU Prolog 1.2.18
By Daniel Diaz
Copyright (C) 1999-2004 Daniel Diaz
| ?-

That is, the variable _L in top/0 cannot be unified at the exit of call_c, like if the inner query was messing with the stack. If I comment the inner query, it works of course. Could someone help me out and tell me if, first, what I try to do is possible with the gprolog interface and how to do it properly? I can't figure it out myself as I guess I exhausted all the examples in the doc.

Thanks in advance for your help, hopefully I could get back to work.


reply via email to

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