Проверьте , как использовать Structs в https://github.com/ffi/ffi/wiki/Structs, для вашего случая:
class What < FFI::Struct
layout :d, :int,
:something, :pointer
end
Теперь присоедините функцию , аргумент, поскольку вы передает структуру по значению , будет What.by_value
(заменив то, что вы назвали выше классом структуры):
attach_function 'doit', [What.by_value],:int
А теперь каквызовите функцию :
mywhat = DoitLib::What.new
mywhat[:d] = 1234
DoitLib.doit(mywhat)
А теперь полный файл:
require 'ffi'
module DoitLib
extend FFI::Library
ffi_lib "path/to/yourlibrary.so"
class What < FFI::Struct
layout :d, :int,
:something, :pointer
end
attach_function 'doit', [What.by_value],:int
end
mywhat = DoitLib::What.new
mywhat[:d] = 1234
DoitLib.doit(mywhat)