LUA pcall 多个返回值
You call lua_pcall
with the number of arguments you are passing and the number of results you want. The fourth argument indicates an error-handling function; we will discuss it in a moment. As in a Lua assignment, lua_pcall
adjusts the actual number of results to what you have asked for, pushing nils or discarding extra values as needed. Before pushing the results, lua_pcall
removes from the stack the function and its arguments. If a function returns multiple results, the first result is pushed first; so, if there are n results, the first one will be at index -n and the last at index -1.
意思就是:当一个函数有多个返回值,第一个返回值首先push,第二个返回值再push,以此类推。
所以要想得到第一个返回值就:lua_toxxxx(L,1),第二个返回值就是lua_toxxxxx(L,2)
本博客注有“转”字样的为转载文章,其余为本人原创文章,转载请务必注明出处或保存此段。c++/lua/windows逆向交流群:69148232