Re: How to catch integer 64 bit return variable type
- Posted by Juergen Luethje <j.lue at gmx.de> Jun 08, 2007
- 574 views
D. Darmawan wrote: > Dear all, > > I'm building a small application using sqlite3 API. The application run > smoothly until an integer field consists a value greater than 32 bit > integer was found on database. Particularly, sqlite3 API has some > functions with 64 bit integer return value (long long int variable > type), but it can't be catch properly in Euphoria since library dll.e > does not provide any constant variable for handling 64 bit integer > return value at all. Trying one of both C_FLOAT and C_DOUBLE only return > a 'nan' value. > > Any information, suggestion or an idea to solve this problem? You need functions like these:
global function peek8u (atom addr) -- returns an *unsigned* 8-byte integer return peek4u(addr+4)*#100000000 + peek4u(addr) end function global function peek8s (atom addr) -- returns a *signed* 8-byte integer atom ret ret = peek4u(addr+4)*#100000000 + peek4u(addr) if ret > #7FFFFFFFFFFFFFFF then ret -= #10000000000000000 end if return ret end function
-- Then in your program use code such as:
myAPIfunc = define_c_func(myDLL, "desired_function", {C_POINTER, C_POINTER}, C_LONG) lpMyVar1 = allocate(8) lpMyVar2 = allocate(8) x = c_func(myAPIfunc, {lpMyVar1, lpMyVar2}) myVar1 = peek8u(lpMyVar1) myVar2 = peek8s(lpMyVar2) free(lpMyVar1) free(lpMyVar2)
Regards, Juergen