Re: [eclipse-clp-users] C Interface Functions does not support int64

From: Hendrik Skubch <hendrik.skubch_at_...196...>
Date: Sun, 25 Oct 2009 13:00:41 +0100
So basically, what you are saying is, that it is not possible to pass a 
double word integer (a long long in C usually) from C to Eclipse.
As a workaround, one could pass multiple integers of word size, and call 
a predicate, which shifts and adds them back together.

concat32(X1,X2,Res):-
	Res  is (X1<<32) + X2.

Not pretty, and one has to take extra care when decomposing signed 
integers in C, but should do the trick.

cheers,
	Hendrik.


Kish Shen wrote:
> Daniel Saur wrote:
>> i use the C Interface Functions in Eclipse (Embedding and Interfacing Manual, 
>> Release 6.0). While i construct a term, i use the function ec_long. But this 
>> function is only for int32, but not for int64. It is possible to build a term 
>> as int64?
> 
> int64 and int32 are *not* standard C types. Standard C integer types do 
> not specify the length of the type, allowing them to be implemented 
> differently on different platforms. int64 and int32 runs counter to 
> this, and I believe they are Microsoft "extensions" (at least 
> originally). So I assume the intention of your question is, can you pass 
> a 64 bit integer to ECLiPSe,  specifically on Windows?
> 
> This is not a question with a simple answer -- because it depends on 
> what platform you are using. In ECLiPSe, integers are stored in a word 
> sized integer, so unless you are running on a (supported) 64 bit 
> platform, you cannot pass a 64 bit integer to ECLiPSe from the standard 
> C/C++ interface. Within ECLiPSe, using GNU's GMP library, integers can 
> be of unlimited size, but this is not exposed via the standard interface.
> 
> Secondly, Windows complicates the issue, because it defines the standard 
>   C integer types differently from every one else. ec_long maps to C 
> type long, and the intention was that this should be the machine word 
> length (i.e. 32 bit on 32 bit machines, 64 bit on 64 bit machines), 
> which is true of most C, except for Windows (MSVC), where long is 32 
> bit, no matter if you are using 64 or 32 bit Windows. So you cannot have 
> 64 bit integers using standard C/C++ types on MSVC.
> 
> ECLiPSe has only been ported to Win64 recently, and it was done on the 
> main development branch, i.e. version 6.1, and not for the released 6.0.
> So potentially, you can only pass 64 bit integers to ECLiPSe on Win64, 
> with ECLiPSe 6.1. However, we did not change the standard C/C++ 
> interface, because we wanted the interface to map to standard C integer 
> types, and long is the longest C integer type that can definitely fit 
> into a machine word in any modern machine.
> 
> Cheers,
> 
> Kish
> 
Received on Sun Oct 25 2009 - 12:26:39 CET

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST