lua-users home
lua-l archive

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


> I did add one more member variable (void* mpMy Data) to lua_State
> structure that I placed before CommonHeader.

You should not do that. Lua assumes that "CommonHeader" is the first
thing in a lua_State, because it can point to a lua_State through a
generic pointer of type GCObject*. If you want to add data to lua_State,
use the LUA_USERSTATE facility. It puts your data before CommonHeader,
but makes the pointer lua_State point to CommonHeader; that is,
you must access your data with something like this:

  ... (lua_State *L) {
    MyData *d = ((MyData *)L - 1);
    ...

-- Roberto