lua-users home
lua-l archive

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

The following codes could perform the bug
//C Source Code
#include "lua.hpp"
int f1(lua_State *L) {
printf("%d\n", lua_tonumber(L, 1));
return 0;
int main (int argc, char* argv[]) {
lua_State *L = luaL_newstate();
lua_pushcfunction(L, f1);
lua_setglobal(L, "f1");
lua_getglobal(L, "f1");
lua_pushnumber(L, 1);
lua_call(L, 1, 0);
return 0;

After executing it,f1 will print 0 on the screen which indicates that it gets nil on stack when it is called.
I don't know if there is anybody else meeting the same problem...
Hope to know what has happened...THX