If I understand this correctly, Lua by default will call the debug library \"debug.traceback\" when an error occurs.
However, when embedding Lua into C code like don
I met the some question as you do,and I found this way work:
luaL_traceback(L, L, NULL, 1);
printf("%s\n", lua_tostring(L, -1));
SinceluaL_traceback
is exactlydebug.traceback()
using to print the stack,so I think this may be a proper way,and you can read the API manual aboutluaL_traceback
or just read the source code of Lua to figure out the what the params means.