I recently used Lua, note.
With the help of others, Lua is based on simplicity and elegance, focusing on the tasks that C is not good. With the help of C/C ++ for its extension, Lua can flash infinite charm.
Make sure that you can directly modify the Lua source code, add the displacement operator, XOR operator, and modify the +,-, and so on to make Lua for yourself.
Continue to use Lua to call the C dynamic library
First, compile the C dynamic library. Of course, it is not a common C dynamic library that can be called by Lua. It is also rule-based:
# Lib. c
# Include "Lua. H "# include" lauxlib. H "# include <stdio. h> static int lua_c_hello () {printf ("C function \ n"); return 1;} static const struct lual_reg mylib [] ={{ "hello", lua_c_hello }, {null, null }}; int luaopen_mylib (lua_state * l) {lual_openlib (L, "mylib", mylib, 0); return 1 ;}
Then compiled into a dynamic library
Gcc-shared-FPIC-O libmylua. So./liblua.
Compile the Lua File
-- Loadlualib. Lua
Function openmylib ()
Local F = assert (loadlib ("/WHC/work/libmylib. So", "mylib "))
F ()
End
Openmylib ();
-- Usemylib. Lua
Require ("loadlualib ")
Mylib. Hello
Oh