Question about call_function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about call_function

Залунин Сергей Александрович
Hello, Luabind-user.

Next code return error message: exception: luabind::cast_failed at memory location 0x003ff68c..

luabind::call_function<char>(myLuaState, "add", "1", "2")





int _tmain(int argc, _TCHAR* argv[])
{
        // Create a new lua state
        lua_State *myLuaState = lua_open();
 
        // Connect LuaBind to this lua state
        luabind::open(myLuaState);
 
        // Define a lua function that we can call
        luaL_dostring(
                myLuaState,
                "function add(first, second)\n"
                "  return first..second\n"
                "end\n"
                );
       
        cout << "Result: "
                << luabind::call_function<char>(myLuaState, "add", "1", "2")
                << endl;
        lua_close(myLuaState);
        _getch();
}
--
С уважением,
 Залунин                          mailto:[hidden email]


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Question about call_function

Willi Schinmeyer
On 12/27/2012 6:11 PM, Залунин Сергей Александрович wrote:
> Hello, Luabind-user.
>
> Next code return error message: exception: luabind::cast_failed at memory location 0x003ff68c..
>
> luabind::call_function<char>(myLuaState, "add", "1", "2")
You're trying to cast a string to char, when it should be char* or
std::string. Try

call_function<string>(myLuaState, "add", "1", "2")


------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user