From 77b8c4dd5274e0c7eea4bae243c36fc8bb04692c Mon Sep 17 00:00:00 2001 From: Luiz Henrique Laurini Date: Thu, 24 Feb 2022 19:28:45 +0100 Subject: [PATCH] Fix undeclared identifier error with Lua 5.4+ The LUA_ERRGCMM constant has been removed. See: https://www.lua.org/manual/5.4/manual.html#8.3 --- Source/Registry/LuaCompiler.cpp | 2 ++ Source/UnitTest/TestLuaCompiler.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Source/Registry/LuaCompiler.cpp b/Source/Registry/LuaCompiler.cpp index ca4223b..2c88b92 100644 --- a/Source/Registry/LuaCompiler.cpp +++ b/Source/Registry/LuaCompiler.cpp @@ -36,9 +36,11 @@ void inline _checkErrorAndThrow(LuaState &L, int error) { case LUA_ERRMEM: throw std::runtime_error("Out of memory"); break; +#if LUA_VERSION_NUM < 504 case LUA_ERRGCMM: throw std::out_of_range("GC Error while loading"); break; +#endif case LUA_ERRSYNTAX: throw std::logic_error(lua_tostring(L,1)); break; diff --git a/Source/UnitTest/TestLuaCompiler.cpp b/Source/UnitTest/TestLuaCompiler.cpp index 7e5a598..fc40c8d 100644 --- a/Source/UnitTest/TestLuaCompiler.cpp +++ b/Source/UnitTest/TestLuaCompiler.cpp @@ -75,7 +75,9 @@ namespace LuaCpp { EXPECT_NO_THROW(_checkErrorAndThrow(*L, LUA_OK)); EXPECT_THROW(_checkErrorAndThrow(*L, LUA_ERRMEM), std::runtime_error); lua_pushstring(*L, "some error"); +#if LUA_VERSION_NUM < 504 EXPECT_THROW(_checkErrorAndThrow(*L, LUA_ERRGCMM), std::out_of_range); +#endif EXPECT_THROW(_checkErrorAndThrow(*L, LUA_ERRSYNTAX), std::logic_error); EXPECT_THROW(_checkErrorAndThrow(*L, 9999), std::runtime_error);