开始使用lua和Luabind1
来源:互联网 发布:tomcat开启debug端口 编辑:程序博客网 时间:2024/05/17 00:51
在c++中调用Lua的函数 :)
#include <iostream>
#include <stdlib.h>
#include <string>
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
#include <luabind/luabind.hpp>
#pragma comment(lib,"lua51.lib")
#pragma comment(lib,"luabind_debug.lib")
using namespace std;
int main()
{
lua_State *myLuaState = luaL_newstate();
luabind::open(myLuaState);
string str = " function sum(l,r) "
"return l + r "
"end";
// 定义一个叫add的Lua函数
luaL_dostring(myLuaState, str.c_str());
//调用add函数
cout << "Result: "
<< luabind::call_function<int>(myLuaState, "sum", 12, 23)
<< endl;
lua_close(myLuaState);
_sleep(1234);
}
大致步骤为建立环境,打开环境,载入字符串,调用对等函数,最后为关闭环境
- 开始使用lua和Luabind1
- 开始使用lua和Luabind2
- 开始学习LUA,在LUA中使用UNICODE字符串
- Lua 开始
- 编译和使用Lua
- 使用Cocos2d-lua开发植物大战僵尸07-实现开始游戏按钮功能和主场景触摸监听
- 从0开始使用Cocos2dx Lua过程记录
- lua 的编译和使用
- Lua CJSON安装和使用
- cocos2dx使用lua和protobuf
- cocos2dx使用lua和protobuf
- cocos2dx使用lua和protobuf
- Lua语法和使用基础
- cocos2dx使用lua和protobuf
- cocos2dx使用lua和protobuf
- Lua CJSON安装和使用
- Lua CJSON安装和使用
- lua函数.和:的使用
- 再读《南宫博士给科学小飞侠阿丁的一封信》
- 今天开始写博客了!
- Oracle千万条记录插入与查询小结
- 匆匆
- 如何在这个网站赚积分啊?
- 开始使用lua和Luabind1
- 超越技术 ——技术商业化成功的决定因素 (之二)
- C/C++中函数指针的含义
- 失败不是我的错?
- 勤奋工作,精彩人生
- JavaScript 调试工具 JSDT
- 命名空间
- IE7下flash无法播放的一种解决方法
- 中国最迷人的八个小镇,你愿意陪我去不?