Compiler errors Lua从5.1更新-Lua_GLOBALSINDEX问题

Compiler errors Lua从5.1更新-Lua_GLOBALSINDEX问题,compiler-errors,lua,global-variables,upgrade,Compiler Errors,Lua,Global Variables,Upgrade,我最近将我的旧Lua 5.1项目更新为该库的最新版本,但我遇到了Lua_GLOBALSINDEX的问题,它变得未定义。我只在lua\u getfield函数中使用它,如下所示: void luastartgame(void) { if(startgamefunction.empty())return ; lua_getfield(globalL, LUA_GLOBALSINDEX, startgamefunction.c_str()); // go to function in

我最近将我的旧Lua 5.1项目更新为该库的最新版本,但我遇到了Lua_GLOBALSINDEX的问题,它变得未定义。我只在
lua\u getfield
函数中使用它,如下所示:

void luastartgame(void)
{
    if(startgamefunction.empty())return ;
    lua_getfield(globalL, LUA_GLOBALSINDEX, startgamefunction.c_str()); // go to function in Lua script
    int numArgs = 0;
    int res = lua_pcall(globalL,numArgs,0, 0);

    if(!luaresf(res)) // did the function call result in an error?
    {
        return;
    }
}
我尝试用一些常量整数替换它-如果它不是0,我的程序就会崩溃。如果为0,则运行异常,抱怨“试图访问nil值”


我的源代码cose可用。我应该如何处理LUA_GLOBALSINDEX?我应该把它改成什么?

使用
lua_getglobal(globalL,startgamefunction.c_str())
,它在5.1和5.2中都可以工作。

你是说lua 5.2,它不是向后不兼容的升级吗?此外,您的问题的答案可以在5.2文档中找到。另请参见和