Skip to content

Instantly share code, notes, and snippets.

@jmettraux
Created February 16, 2009 12:48
Show Gist options
  • Select an option

  • Save jmettraux/65150 to your computer and use it in GitHub Desktop.

Select an option

Save jmettraux/65150 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'ffi'
module Hello
extend FFI::Library
attach_function 'puts', [ :string ], :int
end
Hello.puts("1")
Hello.puts(1)
# jmettraux:~/tmp/ffi$ ruby auto_string.rb
# 1
# (eval):3:in `call1': Invalid String value (ArgumentError)
# from (eval):3:in `puts'
# from auto_string.rb:12
# jmettraux:~/tmp/ffi$ ruby19 auto_string.rb
# 1
# (eval):3:in `call1': Invalid String value (ArgumentError)
# from (eval):3:in `puts'
# from auto_string.rb:12:in `<main>'
# jmettraux:~/tmp/ffi$ jruby-1.1.6 auto_string.rb
# 1
# 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment