Skip to content

Instantly share code, notes, and snippets.

@gutenye
Created May 23, 2012 09:27
Show Gist options
  • Save gutenye/2774210 to your computer and use it in GitHub Desktop.
Save gutenye/2774210 to your computer and use it in GitHub Desktop.
ruby c extension example
# gem install ffi
require "ffi"
module Libc
extend FFI::Library
ffi_lib 'c'
attach_function "printf", [:string, :varargs], :int
end
Libc.printf("cputs %s %d %x", :string, "yoyo", :int, 33, :int, 34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment