Begin forwarded message:
On Feb 18, 2018, at 5:06 PM, Andrew Gierth <firstname.lastname@example.org> wrote:
"Albert" == Albert Chan <email@example.com> writes:
Albert> I have trouble using Lua C stack, even in C
Albert> Say, I have a c function A that uses lua stack, that call
Albert> another c function B that also uses c lua stack. however, B did
Albert> a lua_settop of 1, then return 1.
If A calls B _as a C function_, then B should not be using settop or
making assumptions about the start of the lua stack.
If you want B to be able to use the stack freely without affecting the
caller, then you just call it with lua_pushcfunction and lua_call rather
Andrew.confession time: i wrote B :-(At the time, I HAD to "clean" the stack and return 1(i were not sure which side the 1 referred ... stack 1 ? stack -1 ?)Now, I know return 1 will be enough (if result is at top of stack)B function work perfectly, however, when call from lua.I only noticed the bug when it were called from A, another c-function.