I'm having trouble calling a static class member function (that returns a pointer to a singleton) from a non-class function. When I try to compile (with mingw gcc) I get an error. The problem code is below:
The code works well from inside the IConsole class but but i need to pull it out so that i can eventually run it as a pthread. If I pass the pointer to IConsole to the function like so:Code:void executer(void* params) { FunctionParameters* args = static_cast<FunctionParameters*>(params); std::string name = (*args)[0]; TFunctor* func = IConsole::interface()->getCommand(name); if(func != 0) func->Call(args); else IConsole::interface()->add("Function Not Found"); }
everything works perfectly, except i can't use this to start a pthread. The IConsole->interface() call is used excessively throughout the many classes in the program without any trouble but always from inside a class. Is there some trick to calling the static class member function from a non-member class.Code:void executer(void* params, IConsole* con) { FunctionParameters* args = static_cast<FunctionParameters*>(params); std::string name = (*args)[0]; TFunctor* func = con->getCommand(name); if(func != 0) func->Call(args); else con->add("Function Not Found"); }
Any Ideas greatly appreciated.




Reply With Quote