Subject: [ruby-ffi] Re: long pointer |
From: mydoghasworms |
Date: 2/21/12 6:58 AM |
To: ruby-ffi |
My humble apologies. When I was writing this I was not thinking straight. What I actually meant was a long double, not a long pointer. So for something declared as long double ld; or void foo(long double); what is the corresponding type specification in FFI? On Feb 20, 12:46 pm, Wayne Meissner <wmeiss...@gmail.com> wrote:
Do you mean, a C function with a signature something like: void foo(long *l): In that case, the corresponding ruby-ffi would be: module MyLib extend FFI::LIbrary ffi_lib 'mylib' attach_function :foo, [ :pointer ], :void end and you would invoke it like so: ptr = FFI::MemoryPointer.new(:long) ptr.write_long(0xdeadbeef) MyLib.foo(ptr); # now extract the value the C code filled in l = ptr.read_long