#include <lauxlib.h> #include <lualib.h> #include <stdio.h> #include <string.h> static int (lua_State* L) { double op1 = luaL_checknumber(L,1); double op2 = luaL_checknumber(L,2); lua_pushnumber(L, op1 + op2); printf("test add!!!rn"); return 1; } static int lua_sub(lua_State* L) { double op1 = luaL_checknumber(L,1); double op2 = luaL_checknumber(L,2); lua_pushnumber(L, op1 - op2); printf("test sub!!!rn"); return 1; } static const struct luaL_Reg libt_reg[] = { {"add", lua_add}, {"sub", lua_sub}, {NULL,NULL} }; int luaopen_testlibs_libtt(lua_State *L) { luaL_register(L, "ct", libt_reg); return 1; }
|