#include <math.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
static int my_sum(lua_State *L){
int d1 = luaL_checknumber(L, 1);
int d2 = luaL_checknumber(L, 2);
lua_pushnumber(L, d1+d2);
return 1;
}
static int my_info(lua_State *L){
lua_pushstring(L, "qinuu");
return 1;
}
static const struct luaL_Reg test_lib[] = {
{"my_sum" , my_sum},
{"my_info" , my_info},
{NULL, NULL}
};
int luaopen_test_lib(lua_State *L){
//luaL_newlib(L, test_lib); // 5.2
luaL_register(L, "test_lib",test_lib); // lua 5.1
return 1;
}