Advertisement

[Solved]Unable to pass global object function to globalfunction

Started by June 28, 2013 09:05 PM
2 comments, last by SiCrane 11 years, 5 months ago

I am new to AngelScript and in need of help. ;)

as per the suggestion here.

http://www.angelcode.com/angelscript/sdk/docs/manual/doc_register_func.html








r = engine->RegisterGlobalFunction("void AppName(const Str &in)", asMETHODPR(Application, name,Str,Application), asCALL_THISCALL_ASGLOBAL, &App);

I get error










C2061: syntax error : identifier 'Str'

if I do (Str)

'static_cast' : cannot convert from 'overloaded-function' to 'Application (__thiscall Application::* )(Str)'
1> None of the functions with this name in scope match the target type












r = engine->RegisterGlobalFunction("void AppName(const Str &in)", asMETHOD(Application, name), asCALL_THISCALL_ASGLOBAL, &App);
d:\prod\main.cpp(66): error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'void (__thiscall Application::* )(void)'
1> None of the functions with this name in scope match the target type


struct Application{ // Application Settings

Application& name (const Str &name); // set application name
const Str& name ( ) {return _name ;} // get application name


}extern App

For asMETHODPR() the third parameter should be a parenthesis wrapped list of the parameter types of the member function. In your case you want (const Str &). (Str) doesn't work because your function doesn't actually take a Str, it takes a const Str &.
Advertisement

Unfortunately I've already tried that and it only returns


d:\Prod\main.cpp(66): error C2440: 'static_cast' : cannot convert from 'overloaded-function' to 'Application (__thiscall Application::* )(const Str &)'
1> None of the functions with this name in scope match the target type

Edit:

Ahhh.. forgot Application& at the end instead I had Application...

Thanks for fast reply. :)

The return type also has to match exactly. You have Application when it should be Application &

This topic is closed to new replies.

Advertisement