How to check Lua version in SWIG interface file?
问题 I have the below function which I would like to use only when the Lua version is equal to, or smaller than 5.1 . So I wrote it like the following in myBindings.i file: /* used to backport lua_len to Lua 5.1 */ #if LUA_VERSION_NUM <= 501 %{ static void lua_len(lua_State *L, int i) { switch (lua_type(L, i)) { case LUA_TSTRING: lua_pushnumber(L, (lua_Number)lua_objlen(L, i)); break; case LUA_TTABLE: if (!luaL_callmeta(L, i, "__len")) lua_pushnumber(L, (lua_Number)lua_objlen(L, i)); break; case