Skip to content

Commit ee100ef

Browse files
committed
shared.lua
1 parent 831e429 commit ee100ef

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

section4/lua_shared.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
extern "C" {
99

10+
int num = 10;
1011
int my_add(int a, int b);
1112

1213
}

section4/shared.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ local ffi_new = ffi.new
1010
local ffi_C = ffi.C
1111

1212
ffi_cdef[[
13+
int num;
1314
int my_add(int a, int b);
1415
]]
1516

@@ -20,5 +21,7 @@ print(jit.status())
2021

2122
local shared = ffi_load("./liblua_shared.so")
2223

24+
print(shared.num)
25+
2326
local x = shared.my_add(1, 2)
2427
print(x)

0 commit comments

Comments
 (0)