gpt4 book ai didi

c - Lua C API : pushing function with lua_pushcfunction isn't working

转载 作者:行者123 更新时间:2023-12-04 04:39:41 26 4
gpt4 key购买 nike

它只是崩溃了,我需要你来解决它。提前致谢。

typedef lua_CFunction luaFunc;

int Caller(lua_State* luaVM)
luaFunc Func = lua_tocfunction(luaVM, 1);

lua_pushcfunction(luaVM, Func);
lua_call(luaVM, 0, 0);
return 0;
}

在 Lua 中它应该是这样的:
function Caller(f)
f()
end

最佳答案

相当于 Lua 代码

function Caller(f)
f()
end


int Caller(lua_State* luaVM)    
lua_call(luaVM, 0, 0);
return 0;
}

关于c - Lua C API : pushing function with lua_pushcfunction isn't working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19078794/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com