[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Returning data from C functions called using "loadlib".
- From: Aaron Newell <add_aaron_2_x@...>
- Date: Tue, 31 Aug 2004 16:29:46 +0100 (BST)
Thanks but that doesnt seem to work:
extract from c file:
static int functionFromCLibrary(lua_State* L)
{
int a = (int)lua_tonumber(L, -1);
printf("cfunction: %d\n", a);
a = a + 1;
printf("cfunction now: %d\n", a);
return a;
}
lua command prompt:
> yes = 1
> print(yes)
1
> yesyes = functionFromCLibrary(yes)
> print(yesyes)
function: 0x1033b0
It doesnt seem to be returning my number. Just a
pointer to the c function.
> Date: Mon, 30 Aug 2004 17:40:21 -0500
> From: Rici Lake <lua@ricilake.net>
> Subject: Re: Returning data from C functions called
> using "loadlib".
> To: Lua list <lua@bazar2.conectiva.com.br>
>
> If what you mean is:
>
> local a = 3
> cfunction(a)
> -- now a has magically become 5
>
> Then you can't do it, in Lua or any sensible
> language ;)
> (Well, we all have our biases.)
> In Lua, all arguments are passed by value.
>
> Do this:
>
> a = cfunction()
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com