You are not logged in.
Resolution: It seems that GCC does not like anonymous structs defined inside of functions being passed as the arguments. So in order to make it compile and such for the time being, I simply defined the structs at the top of the file and changed the other code accordingly. I hope this helps anyone else who might get stuck on this. Cheers. =]
----------------------------------------------------
I have been having this problem for a while, although I got it to compile by declaring the functor struct with ": function<void (Player *)>" after it. However, this only got it to compile rather than actually work. So I am hoping that someone here might have a possible solution for the problem. Now onto the code and such.
if (command == "me") {
if (args.length() == 0)
return;
string msg = player->getName() + " : " + args;
struct {
void operator()(Player *gmplayer) {
if (gmplayer->isGM() == true) {
PlayerPacket::showMessage(gmplayer, msg, 6);
}
}
string msg;
} sendMessage = {msg};
Players::Instance()->run(sendMessage);
}
The errors:
ChannelServer/ChatHandler.cpp||In function 'void ChatHandler::handleChat(Player*, PacketReader&)':
ChannelServer/ChatHandler.cpp|163|error: no matching function for call to 'Players::run(ChatHandler::handleChat(Player*, PacketReader&)::<anonymous struct>&)'
ChannelServer/Players.h|47|note: candidates are: void Players::run(boost::function<void ()(Player*)>)
If it helps, this is the declaration of the Players::run function.
void run(function<void (Player *)> func);
Thanks in advance for any help you all can give. Cheers. =]
Last edited by emily (2008-12-24 22:05:58)
Offline
Good thing you found a solution.
I've had similiar problems from time to time.
One of the few part of C++ I don't like... Include .h here and there, forward declarations etc, becomes a mess after a while if you've got lots of files.
Offline