我怎么能从C知道Lua函数的返回值计数?

|
luaL_loadstring(L, \"return 3, 4, 5\");
int R       =   lua_pcall(L, 0, 3, 0);
Lua可以返回多个值。但是目前我必须对返回值的计数进行硬编码。我可以在运行时动态知道计数吗?     
已邀请:
        是。
int top = lua_gettop(L);
luaL_loadstring(L, \"return 3, 4, 5\");
int R = lua_pcall(L, 0, LUA_MULTRET, 0);
int nresults = lua_gettop(L) - top;
使用
LUA_MULTRET
,然后使用
lua_gettop
找出调用之前和之后的堆栈顶部。     

要回复问题请先登录注册