lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


$ sudo luarocks install apidemo
[sudo] password for dirk:
Installing https://rocks.moonscript.org/apidemo-1.0-2.src.rock...
Using https://rocks.moonscript.org/apidemo-1.0-2.src.rock... switching
to 'build' mode
gcc -O2 -fPIC -I/home/dirk/include -c apidemo.c -o apidemo.o
apidemo.c: In function ‘setup_globals’:
apidemo.c:929:18: error: ‘LUA_GLOBALSINDEX’ undeclared (first use in
this function)
   register_const(LUA_GLOBALSINDEX);
                  ^
apidemo.c:831:33: note: in definition of macro ‘register_const’
   lua_pushnumber(L, (lua_Number)const_name);   \
                                 ^
apidemo.c:929:18: note: each undeclared identifier is reported only
once for each function it appears in
   register_const(LUA_GLOBALSINDEX);
                  ^
apidemo.c:831:33: note: in definition of macro ‘register_const’
   lua_pushnumber(L, (lua_Number)const_name);   \
                                 ^

Error: Build error: Failed compiling object apidemo.o

2015-12-01 12:44 GMT+02:00 Tyler Neylon <tylerneylon@gmail.com>:
> The apidemo module mimics Lua's C API within Lua itself.
>
> It's meant to help folks learn the API by using it interactively from
> the interpreter. They can see directly how each call affects the
> stack.
>
> For example:
>
>> apidemo = require 'apidemo'
>> apidemo.setup_globals()
>> L = luaL_newstate();  -- Using semicolons to be more C-like.
>> lua_getglobal(L, "print");
> stack: function:print
>> lua_pushstring(L, "hi!");
> stack: function:print 'hi!'
>> lua_call(L, 1, 0);
> hi!
> stack: <empty>
>
> This is available via luarocks. The source and more info can be found here:
>
> https://github.com/tylerneylon/lua_api_demo
>
> thanks!
>  - Tyler
>