代码拉取完成,页面将自动刷新
#include <stdio.h>
#include "lua5.4/lua.h"
#include "lua5.4/lauxlib.h"
// 函数必须以C的形式被导出
extern "C" int hello (lua_State *L) {
printf("hello world , there is cpp code !");
return 0;
}
static const struct luaL_Reg alib [] = {
{"hello", hello},
{NULL, NULL}
};
// loader函数 myclib 决定 require "myclib" 的命名
// 必须为 luaopen_xxx
extern "C" int luaopen_mycpplib(lua_State *L) {
// 新建一个库(table),把函数加入这个库中,并返回
luaL_newlib(L, alib);
return 1;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。