[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Stack empty after lua_pcall error
- From: William Riancho <wr.wllm@...>
- Date: Tue, 15 May 2012 19:53:35 +0200
Hello,
I have a problem using the Lua C API. When lua_pcall fails, the error
is pushed on the stack. So when you pop the stack you get the error
but when you count elements in stack you get 0.
#include <lua5.2/lauxlib.h>
#include <lua5.2/lua.h>
#include <lua5.2/lualib.h>
int main()
{
lua_State *L = luaL_newstate();
lua_pcall(L, 0, 0, 0);
printf("%d %s\n", lua_gettop(L), lua_tostring(L, -1));
}
Compile with: gcc main.c `pkg-config --cflags lua5.2` `pkg-config --libs lua5.2`
This program display:
0 attempt to call a nil value.
The behavior is the same with the 5.1 version.