Introduction
鉴于lua5.4版本取消了luaL_register之后,网上教程的混乱,这里以5.4版本为例,用luaL_setfuncs来代替。
Results
完整C代码
代码如下:
#ifdef __cplusplus
extern "C" {
#include <lua.hpp>
#include <lualib.h>
#include <lauxlib.h>
#include <luaconf.h>
}
#else
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <luaconf.h>
#endif
#include <string.h>
#include <stdio.h>
extern "C"

这篇博客介绍了在lua5.4版本中,由于luaL_register被取消,如何使用luaL_setfuncs来调用C++程序。博主通过实例展示了C代码和lua代码的正确实现,并解释了luaL_setfuncs的参数含义,指出参数设置不当可能导致的问题。
最低0.47元/天 解锁文章
3008

被折叠的 条评论
为什么被折叠?



