Skip to content

Instantly share code, notes, and snippets.

@tiffany352
Created January 14, 2013 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiffany352/4528471 to your computer and use it in GitHub Desktop.
Save tiffany352/4528471 to your computer and use it in GitHub Desktop.
[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
typedef float test_arr[16];
test_arr global_arr;
int test_fn(test_arr arr) {
(void)arr;
printf("hello, world\n");
return 0;
}
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