users-prolog
[Top][All Lists]
Advanced

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

Negative integer passing from C to GNU-Prolog


From: Shuai Wang
Subject: Negative integer passing from C to GNU-Prolog
Date: Sat, 16 Aug 2014 17:30:45 -0400

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




Attachment: main.c
Description: Text Data

Attachment: test.pl
Description: Text Data

Attachment: test.c
Description: Text Data

Attachment: Makefile
Description: Binary data


reply via email to

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