lua-users home
lua-l archive

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


Hell no... that works!!! Thanks a lot Rici. Fixed with figureout(const char
*what, int ever).

Again, thanks.

Rafael

-----Mensagem original-----
De: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] Em nome de Rici Lake
Enviada em: segunda-feira, 2 de julho de 2007 18:24
Para: Lua list
Assunto: Re: RES: RES: C++ Typecast - so far newbie question


On 2-Jul-07, at 3:05 PM, SosCpdTerra wrote:

> What are you talking about? I cannot pass this return value to a 
> variable
> and typecast into whatever I want? I guess this is the evil!!

If you want a mutable copy of the string, you need to make a copy of 
the string.

>
> Like:
>
> I have this
> void figureout(char *what, int ever)
>
> and I must his 2 args came from lua. Im trying to do this:
>
> int serial(lua_State *L) //my registered function
>     {
>         int argc = lua_gettop(L);
>         const char var1 = lua_tostring(L, 1);
>         int var2 = int(lua_tonumber(L, 2));
>         figureout(var1, var2);
>         return 0;
>     }
>
> There is another way? I can't see that way, and that is my problem.

Declare figureout properly:

void figureout(const char *what, int ever)

Functions which take string arguments and do not modify them should not 
be declared as taking char *.



__________ NOD32 2371 (20070702) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com