C++使用Lua


a

Hello World

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
extern "C"
{
#include "lauxlib.h"
#include "lua.h"
#include "lualib.h"

}
#include <string.h>

int main(int argc, char *argv[])
{
// initialization
lua_State *L = lua_open();
luaL_openlibs(L);

// execute script
const char lua_script[] = "print('Hello World!')";
int load_stat = luaL_loadbuffer(L, lua_script, strlen(lua_script), lua_script);
lua_pcall(L, 0, 0, 0);

// cleanup
lua_close(L);
return 0;
}

相关文章

Using Lua with C++ (Part 1)

Lua written in modern C++ (>= 14)?

BindingCodeToLua