summaryrefslogtreecommitdiff
path: root/tests/C/lua_call.c
blob: 3e0e406dda01599ef505d402178a11d3915d6557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <stdlib.h>
#include <stdio.h>

int func(lua_State *L) {
    lua_pushstring(L, "hello");
    return 1;
}

int main(void) {

    lua_State *L = luaL_newstate();

    luaL_openlibs(L);

    lua_pushcfunction(L, func);

    lua_call(L, 0, 1);

    printf("Lua returned: %s\n", lua_tostring(L, -1));

    lua_close(L);

    return 0;

}