Closed vsergeev closed 4 years ago
local ffi = jit and require('ffi') or require('cffi') --[[ /* testlib.c */ /* gcc -shared testlib.c -o testlib.so */ #include <stdio.h> struct foo { int a; int b; }; void print_foo(struct foo x) { printf("foo<%d, %d>\n", x.a, x.b); } void print_const_foo(const struct foo x) { printf("foo<%d, %d>\n", x.a, x.b); } ]]-- ffi.cdef[[ struct foo { int a; int b; }; void print_foo(struct foo x); void print_const_foo(const struct foo x); ]] local testlib = ffi.load('./testlib.so') local foo = ffi.new("struct foo", 1, 2) testlib.print_foo(foo) --> expected: foo<1, 2>, get: cannot convert 'struct foo' to 'struct foo' testlib.print_const_foo(foo) --> expected: foo<1, 2>, get: cannot convert 'struct foo' to 'struct foo'