Created
January 14, 2013 07:43
-
-
Save tiffany352/4528471 to your computer and use it in GitHub Desktop.
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
[tiffany@arch scripts]$ gcc -shared luajit_test.c -o libluajit_test.so | |
[tiffany@arch scripts]$ export LD_LIBRARY_PATH=. | |
[tiffany@arch scripts]$ luajit luajit_test.lua | |
hello, world | |
0 |
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
typedef float test_arr[16]; | |
test_arr global_arr; | |
int test_fn(test_arr arr) { | |
(void)arr; | |
printf("hello, world\n"); | |
return 0; | |
} |
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
local ffi = require "ffi" | |
local lib = ffi.load "luajit_test" | |
ffi.cdef [[ | |
typedef float test_arr[16]; | |
test_arr global_arr; | |
int test_fn(test_arr arr); | |
]] | |
print(lib.test_fn(lib.global_arr)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment