lua-users home
lua-l archive

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

Hi @ll,

I am using lua_pushuserdata to exchange pointers between C-program and LUA-script, and I just found something weird: When I push
NULL from the C-function like this:
    CObject* O = NULL; // CObject is a class declared in my program
    // doing something here, O might remain NULL or become something else
    lua_pushuserdata (m_pLuaState, O);
    return 1;
the result of the calling LUA function - which looks similar to this: -
    result_ptr = myfunction ()
get's anything, but never "nil" when it should.

I worked around that by pushing "0" as a number, but I am still wondering why it does not work with NULL as userdata.
lua_pushuserdata _should_ work with a NULL pointer for obvious reasons. Any ideas?


Matthias Gall, lead programmer at sechsta sinn