Skip to content

Instantly share code, notes, and snippets.

@jesg
Created June 13, 2015 10:10
Show Gist options
  • Save jesg/22ee2f7ab426a0cc69a7 to your computer and use it in GitHub Desktop.
Save jesg/22ee2f7ab426a0cc69a7 to your computer and use it in GitHub Desktop.
embed nim in ruby
# nim c --app:lib --noMain --header:hello.h hello.nim
proc foo*(a: cint): cint {. exportc .} =
result = a
require 'ffi'
module Hello
extend FFI::Library
ffi_lib './libhello.so'
attach_function :NimMain, [], :void
attach_function :foo, [:int], :int
end
Hello.NimMain
puts Hello.foo(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment