diff --git a/include/sol/compatibility/compat-5.3.h b/include/sol/compatibility/compat-5.3.h index 8d32d2d7..bd9dad99 100644 --- a/include/sol/compatibility/compat-5.3.h +++ b/include/sol/compatibility/compat-5.3.h @@ -405,11 +405,11 @@ COMPAT53_API void luaL_requiref(lua_State *L, const char *modname, /* other Lua versions */ -#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504 +#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 505 -# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)" +# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, 5.4 or 5.5)" -#endif /* other Lua versions except 5.1, 5.2, 5.3, and 5.4 */ +#endif /* other Lua versions except 5.1, 5.2, 5.3, 5.4 and 5.5 */ diff --git a/include/sol/compatibility/compat-5.4.h b/include/sol/compatibility/compat-5.4.h index ae747c64..b5238579 100644 --- a/include/sol/compatibility/compat-5.4.h +++ b/include/sol/compatibility/compat-5.4.h @@ -17,15 +17,15 @@ extern "C" { } #endif -#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504 +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 504 #if !defined(LUA_ERRGCMM) -/* So Lua 5.4 actually removes this, which breaks sol2... +/* So Lua 5.4 or later actually removes this, which breaks sol2... man, this API is quite unstable...! */ # define LUA_ERRGCMM (LUA_ERRERR + 2) #endif /* LUA_ERRGCMM define */ -#endif // Lua 5.4 only +#endif // Lua 5.4 or later #endif // NOT_KEPLER_PROJECT_COMPAT54_H_ \ No newline at end of file diff --git a/include/sol/state.hpp b/include/sol/state.hpp index ed2412ed..b05e9741 100644 --- a/include/sol/state.hpp +++ b/include/sol/state.hpp @@ -27,6 +27,12 @@ #include #include +#if LUA_VERSION_NUM >= 505 +# define sol_lua_newstate(f, ud) lua_newstate(f, ud, 0) +#else +# define sol_lua_newstate(f, ud) lua_newstate(f, ud) +#endif + namespace sol { class state : private std::unique_ptr, public state_view { @@ -39,7 +45,7 @@ namespace sol { } state(lua_CFunction panic, lua_Alloc alfunc, void* alpointer = nullptr) - : unique_base(lua_newstate(alfunc, alpointer)), state_view(unique_base::get()) { + : unique_base(sol_lua_newstate(alfunc, alpointer)), state_view(unique_base::get()) { set_default_state(unique_base::get(), panic); }