[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Problem with userdata (metatable)
- From: "Anders Bergh" <anders@...>
- Date: Wed, 12 Apr 2006 21:05:06 +0200
Hmm, I tried this:
struct user *llua_pushuser (lua_State *L, struct user *user_ptr) {
struct user **l_user = (struct user**)lua_newuserdata(L,
sizeof(struct user*));
*l_user = user_ptr;
luaL_getmetatable(L, TYPE);
lua_setmetatable(L, -2);
return *l_user; /* is this right? using return l_user made gcc say
warning: return from incompatible pointer type */
}
Output:
PrintUserInfo: 0x8158a4c
-> nick: ÐØ
-> numeric: ¸øí·
-> oper: 96
Segmentation fault
Anders
On 4/12/06, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> > struct user *llua_pushuser (lua_State *L, struct user *user_ptr) {
> > struct user *l_user = (struct user*)lua_newuserdata(L, sizeof(struct user*));
>
> I think you need this:
>
> struct user **l_user = (struct user**)lua_newuserdata(L, sizeof(struct user*));
> *l_user = user_ptr;
>