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_pcallremoves 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)

LUA pcall 多个返回值的更多相关文章

  1. lua调用c++函数返回值作用

    2015/05/28 lua调用c++接口,返回给lua函数的是压入栈的内容,可以有多个返回值.但是c++接口本身也是有返回值的,这个返回值也非常的重要,会决定最后返回到lua函数的值的个数. (1) ...

  2. C++获取Lua全局变量和执行Lua多参数多返回值函数

    C++代码: // LuaAndC.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #i ...

  3. Lua 中string.gsub(sourceString, pattern, replacementString) 返回值有两个

    这阵子在学习lua,今天看到string操作,书中描述string.gsub(sourceString, pattern, replacementString)返回一个字符串,但是我在实际操作中却发现 ...

  4. <5>Lua多返回值和require模块

    1.多返回值 --1: 一个lua函数可以返回多个返回值: --2: 定义多个变量来接受多返回值 --3: lua的unpack函数,解开表里的单个的值; 结果 2.require模块 --1: 第一 ...

  5. lua入门之二:c/c++ 调用lua及多个函数返回值的获取

    当 Lua 调用 C 函数的时候,使用和 C 调用 Lua 同样类型的栈来交互. C 函数从栈中获取她的參数.调用结束后将返回结果放到栈中.为了区分返回结果和栈中的其它的值,每一个 C 函数还会返回结 ...

  6. Lua中返回值的丢失问题

    Lua中返回值的丢失问题 -- 如果函数调用所得的多个返回值是另外一个函数的最后一个参数,或者是多指派表达式中的最后一个参数时,所有返回值将被传入或使用. -- 否则只有第一个返回值被使用或指定. T ...

  7. lua 基础 2 类型和值

    -- 类型 和 值--[[ 8中类型 滚动类nil.boolean. number.string.userdata.function.thread 和 table.]] print (type(&qu ...

  8. Lua中的类型与值

    [基础介绍] Lua是一种动态类型的语言.在语言中没有类型定义的语法,每个值都带有其自身的类型信息.在Lua中有8中基本类型,分别是: nil(空)类型 boolean(布尔)类型 number(数字 ...

  9. Lua学习之类型与值

    Lua是一种动态语言,在语言中没有类型定义的语法. 在lua中有8中基本的类型: 1.nil(空) 2.boolean 3.number(数字) 4.string(字符串) 5.userdata(自定 ...

随机推荐

  1. C# 播放铃声最简短的代码实现方式

    因为只是做一个软件的闹铃播放效果,到网上找的时候试了几种,哎,都失败了,而且代码挺杂的,最终一句搞定了: 1         // 窗体加载事件 2         private void Time ...

  2. 【中文分词系列】 4. 基于双向LSTM的seq2seq字标注

    http://spaces.ac.cn/archives/3924/ 关于字标注法 上一篇文章谈到了分词的字标注法.要注意字标注法是很有潜力的,要不然它也不会在公开测试中取得最优的成绩了.在我看来,字 ...

  3. 实战HMM-Viterbi角色标注地名识别

    http://www.hankcs.com/nlp/ner/place-names-to-identify-actual-hmm-viterbi-role-labeling.html 命名实体识别(N ...

  4. 从头来之【iOS及历史版本特性介绍】

    iOS是apple公司的移动操作系统,在iPhone,iPad,iPod中应用,该名最初为Cisco的网络设备操作系统,后授权于Apple公司使用.下面介绍历史版本的特性. iOS1 最大特性是具有其 ...

  5. common.js 2017

    String.IsNullOrEmpty = function (v) { return !(typeof (v) === "string" && v.length ...

  6. Python在线dlib库地址

    一.地址 https://pypi.python.org/pypi/dlib/18.17.100

  7. Hotmail Smtp邮箱发送的端口

    1.最近有项目需求做监控报警. 2.使用Smtp发邮件时,网上找了一大堆,Smtp服务是:smtp.live.com   端口是:25或587,试了好多次都不行.原来端口是465. 3.发送时,我启用 ...

  8. C#实现U盘检查,并写入文件

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. JAVA开发总结

    1.Float取整 long warning; float fwarning = 0f; fwarning = total*0.34/100; warning = new Float(fwarning ...

  10. JavaScript正则式练习

    使用正则式匹配第一个数字和最后一个数字,使用环视 str2 = 09051 : Fast Food Restaurants - Concession Stands/Snack Bars Delicat ...