May 2017
Intermediate to advanced
416 pages
21h 33m
English
Let's go through the process of creating a C library and accessing it with the Lua C API. Our module will only contain a single function that prints a message on screen:
extern "C" { #include "lauxlib.h" #include "lua.h" } #include "nse_test.h" static int hello_world(lua_State *L) { printf("Hello World From a C library\n"); return 1; } static const struct luaL_Reg testlib[] = { {"hello", hello_world}, {NULL, NULL} }; LUALIB_API int luaopen_test(lua_State *L) { luaL_newlib(L, testlib); ...Read now
Unlock full access