Last active
May 16, 2020 03:14
-
-
Save bartojs/1c8eb360ca8a6dc0365d to your computer and use it in GitHub Desktop.
Call libC using jnr-ffi in clojure
This file contains hidden or 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
boot -d com.github.jnr/jnr-ffi repl | |
=> (import jnr.ffi.LibraryLoader) | |
=> (definterface LibC (^int puts [^String s])) | |
=> (def libname (if (.contains (.toLowerCase (System/getProperty "os.name")) "windows") "msvcrt" "c")) | |
=> (def libc (.load (LibraryLoader/create LibC) libname)) | |
=> (.puts libc "Hello World") | |
Hello World | |
10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment