使用lua5.2发现编译器找不到lua_open函数,最后发现这个函数在5.2中已经被遗弃,被新的函数luaL_newstate和lua_newstate替代。lua_newstate可自定义内存分配函数,luaL_newstate使用默认的内存分配方式。
下面是5.2中头文件部分定义
/* compatibility with old module system */
#if defined(LUA_COMPAT_MODULE)
LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
int sizehint);
LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
const luaL_Reg *l, int nup);
#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0))
#endif