【发布时间】:2017-09-05 20:49:01
【问题描述】:
- 一个lua函数返回两个数字
- c++调用lua函数:foo
- 不知道是否需要pop函数foo(lua_pop(L,2);)的返回值。
- 请告诉我怎么做以及为什么。非常感谢。
部分代码如下:
// lua function
function foo(a, b)
return a+b, a-b;
end
// c++
lua_getglobal(L,"foo"); // push function
lua_pushnumber(L,1); // push argument 1
lua_pushnumber(L,2); // push argument 2
error=lua_pcall(L, 2, 2, 0);
if (!error) {
printf("return:%s\n",lua_tostring(L,-1));
printf("return:%s\n",lua_tostring(L,-2));
// is this needful
lua_pop(L,2);
}
【问题讨论】:
标签: lua