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" int