Skip to content

Commit d19d080

Browse files
johncarmack1984systemed
authored andcommitted
Fix Lua 5.4 compatibility in kaguya.hpp
Some Lua 5.4 builds (e.g., vcpkg) removed LUA_GCSETPAUSE and LUA_GCSETSTEPMUL constants, replacing them with LUA_GCPPAUSE and LUA_GCPSTEPMUL. Add conditional defines to handle both cases.
1 parent 16c2955 commit d19d080

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

include/external/kaguya.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ extern "C" {
1818
#include <lualib.h>
1919
}
2020

21+
// Lua 5.4 compatibility: Some builds removed LUA_GCSETPAUSE/LUA_GCSETSTEPMUL
22+
// Check if old constants exist, otherwise define them using the new names
23+
#if !defined(LUA_GCSETPAUSE) && defined(LUA_GCPPAUSE)
24+
#define LUA_GCSETPAUSE LUA_GCPPAUSE
25+
#endif
26+
#if !defined(LUA_GCSETSTEPMUL) && defined(LUA_GCPSTEPMUL)
27+
#define LUA_GCSETSTEPMUL LUA_GCPSTEPMUL
28+
#endif
29+
2130
#ifndef KAGUYA_USE_CPP11
2231
#if defined(__cpp_decltype) || __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
2332
#define KAGUYA_USE_CPP11 1
@@ -12495,7 +12504,7 @@ namespace kaguya
1249512504

1249612505
/// @brief sets arg as the new value for the pause of the collector. Returns the previous value for pause.
1249712506
int steppause(int value) { return lua_gc(state_, LUA_GCSETPAUSE, value); }
12498-
12507+
1249912508
/// @brief sets arg as the new value for the step multiplier of the collector. Returns the previous value for step.
1250012509
int setstepmul(int value) { return lua_gc(state_, LUA_GCSETSTEPMUL, value); }
1250112510

0 commit comments

Comments
 (0)