Created
June 13, 2015 10:10
-
-
Save jesg/22ee2f7ab426a0cc69a7 to your computer and use it in GitHub Desktop.
embed nim in ruby
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
# nim c --app:lib --noMain --header:hello.h hello.nim | |
proc foo*(a: cint): cint {. exportc .} = | |
result = a |
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 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