[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: is this a bug in lua core 5.0b ?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 30 Jan 2003 16:13:30 +0000
> 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