From: DaZoner Date: 2004-12-16T01:17:25+09:00 Subject: Re: 64-bit integers in Ruby/DL I don't know very much about Ruby/DL but can't you just define a struct that has two 32-bit numbers in it, and manipulate and pass those? "Jamis Buck" wrote in message news:20041214220549.GA15605@serling.WorkGroup... > Okay, you C gurus out there. Here's a stumper. > > Is there any way, without modifying Ruby/DL itself, to specify > a function that returns a 64-bit integer using Ruby/DL? And to pass > a 64-bit integer to a function? > > Consider: > > require 'dl/import' > module Test64 > dlload "foo.so" > extern "long long int get_64bit_value()" > extern "void set_64bit_value(long long int)" > end > > The above results in an error, currently, because Ruby/DL does not > support 64-bit integers as immediate values. > > I thought of using a double (which is 64 bits, on my platform anyway): > > require 'dl/import' > module Test64 > dlload "foo.so" > extern "double get_64bit_value()" > extern "void set_64bit_value(double)" > end > > result = Test64.get_64bit_value > p [result].pack("D").unpack("LL") > > But the value that comes back is nothing like what the function itself > is really returning... > > Any clever tricks I can try? Anyone? Please? > > - Jamis > > -- > Jamis Buck > jgb3@email.byu.edu > http://www.jamisbuck.org/jamis > > >