Sign in to follow this  
Followers 0
Zykomaniac

[Solved]Unable to pass global object function to globalfunction

3 posts in this topic

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

Edited by Zervoxe
0

Share this post


Link to post
Share on other sites
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 &.
0

Share this post


Link to post
Share on other sites

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. :)

Edited by Zervoxe
0

Share this post


Link to post
Share on other sites
The return type also has to match exactly. You have [tt]Application[/tt] when it should be [tt]Application &[/tt]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0