Hello Prolog users,
I am trapped in passing negative integer value from C to Prolog using the interface.
Here is the thing,
I have two files, one Prolog source code and a C source code.
Basically a variable defined in C has the value (-2), and the Prolog code tries to read it in.
I use the standard interface like this in Prolog to get the value:
:- foreign(c_foo( -integer)).
However, even though the value defined in C code is -2, what I got in Prolog (I write it out in Prolog after the above wrapper return) is 4294967294
Follow the
instruction, I tried other Foreign Type (positive, number ) which are like
:- foreign(c_foo( -positive)).
:- foreign(c_foo( -number)).
But it still gives me the wrong answer...
So I am wondering if it is possible to pass a negative integer from C to GNU-Prolog..?
The attachments are the source code and Makefile, I have simplified it and hope it could be understandable.
The test is on Linux 14.04 64bit, GNU -Prolog 1.3.0
Am I clear enough? Could anyone give me some help?
Best,
Shuai