lua-users home
lua-l archive

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

On Fri, Aug 26, 2011 at 5:58 PM, liam mail <> wrote:
> I am just looking for some clarification when using the macro
> LUA_USE_APICHECK, is it the case that indicators in the manual are not
> respected for functions when using this macro? I ask because I decided
> to turn the option on and run unit tests on OOLua to find that an
> assert is being triggered for the function lua_touserdata (indirectly
> via index2addr) with it, yet the manual states "'-' means the function
> never throws any error". The situation under test was trying to pull a
> user data of an empty stack which as I understood it would return NULL
> and does without the macro, this situation is handled gracefully in
> the test but means I can not use the macro as is. Firstly because an
> assert (from assert.h) in unit tests is bad and also it would require
> different tests for release and debug builds.
> Thanks
> Liam

I suggest checking the stack height before trying to remove things from it.

The Lua API is very much garbage in - garbage out, bad API usage has
undefined behavior which is why APICHECK exists in order to provide
more robust API checking.

Errors in this instance refer to Lua errors, not any kind of C
assertions or error handling.