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); }