[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: What's the point of LUA_USERSTATE?
- From: Diego Fernandes Nehab <diego@...>
- Date: Fri, 3 May 2002 03:09:55 -0300 (BRT)
> I was trying to see if I can get away with defining LUA_USERSTATE before
> including lua.h instead of modifying Lua to store and expose user data
> (which I do currently), but since the definition of lua_State isn't
> included in lua.h, how are you supposed to access LUA_USERSTATE given a
Let's say you want to store a (void *) in LUA_USERSTATE.
Define LUA_USER_H to be "your.h" and define LUA_USERSTATE to be something
#define LUA_USER_H void *yourfield;
Since all lua files include lua.h, and lua.h includes LUA_USER_H,
all lua files will notice your definition.
After that, since LUA_USERSTATE is included as the first field of
lua_State, you can cast your lua_State *pointer to a (void **) and access
*((void **) L) = NULL; /* for instance */