Created
November 2, 2016 11:46
-
-
Save mzumi/c0b5aaf6b50d033ca3a92bb9907a94bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
module FFISample | |
extend FFI::Library | |
ffi_lib 'target/release/libffi_sample.dylib' | |
class SampleStruct < FFI::Struct | |
layout :i, :int, | |
:b, :bool, | |
:s, :string | |
end | |
attach_function :create_sample_struct, [:pointer], :void | |
end | |
st = FFISample::SampleStruct.new | |
FFISample.create_sample_struct(st.pointer) | |
puts "i: #{st[:i]}, b:#{st[:b]}, s:#{st[:s]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment