Jump to content
  • Advertisement
Sign in to follow this  
nilkn

Interesting error (C++)...

This topic is 4880 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm sorry, I feel like an idiot for not being able to solve this... Anway, first feast your eyes on this:
// ...

class xrMessagePump
{
public:
	static void SendMessage(xrMessagePtr Message);
	static void SendMessage(int DestID, xrPtr<xrClass> Sender, string Message, float Delay, int Priority, boost::any Arg1);
        // ...     
};

// in a completely different file, many light years away...

void WorldMap::CALLBACK_Render::Function(xrMessagePtr Msg, xrClass* Parent)
{

	WorldMap* parent = static_cast<WorldMap*>(Parent);

	xrMessagePump::SendMessage(parent->m_WaterTiles->GetUID(), this, "RepeatingTileMap_Render", 0.0f, xrMessage::MESSAGE_PRIORITY_IMMEDIATE, NULL);

        // ^^ this line is the culprit.
}


The marked line is causing these errors:
Quote:
c:\Documents and Settings\Owner\My Documents\Code\Projects\War of the Seas\WorldMap.cpp(48): error C2039: 'SendMessageA' : is not a member of 'xrMessagePump' c:\Documents and Settings\Owner\My Documents\Code\Projects\War of the Seas\MessageSystem.hpp(117) : see declaration of 'xrMessagePump' c:\Documents and Settings\Owner\My Documents\Code\Projects\War of the Seas\WorldMap.cpp(48): error C2660: 'SendMessageA' : function does not take 6 arguments
This has thoroughly confused me. For one thing, why is there an 'A' appended to the function name? And why are those errors even being thrown? I call the same function with nearly identical parameters elsewhere in the code without getting any errors. For example, this code compiles fine:
xrMessagePump::SendMessage(m_CurrMap->GetUID(), this, "Map_Render", 0.0f, xrMessage::MESSAGE_PRIORITY_PERIODIC, NULL);
And as for the second error, I think it's just a consequence of the first, since the function does indeed take 6 parameters. Anyway, can someone please help me out here? I feel as if I'm overlooking something obvious, but I'm not sure... Thanks for your time!

Share this post


Link to post
Share on other sites
Advertisement
To provide support for both ASCII and Unicode application, Win32 has macros that remaps text-manipulating functions like SendMessage to SendMessageA and SendMessageW (I think). With a few additional conventions to follow (e.g. TCHAR), you don't have to modify your application to recompile it with Unicode support.

Macros are dumb. They do not differenciate between their intended target and an identically named member function (it's just raw text substitution).

Name your function differently or undefine the macro.

Macros are evil.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You just have a naming conflict. SendMessage is a window macro, See winuser.h

Share this post


Link to post
Share on other sites
SendMessage is #defined in by windows.h to be either SendMessageA or SendMessageW depending on whether you're using unicode or not. Basically, you can either rename your function, or #undef SendMessage for that file.

tj963

Share this post


Link to post
Share on other sites
This has to do with the Windows headers having #defines for every function that is impacted by Unicode/Non-Unicode. Based on a #ifdef, if Unicode is being used, SendMessage is #define'd as SendMessageW. If Unicode is not being used, then it is defined as SendMessageA.

So, if you have any functions/methods with the same name as one of those Windows functions, the #define's will affect them and any calls to them, too.

The only way around this is to make sure you don't name your functions/methods the same as any Windows API functions.

edit - boy, aren't we all johnny on the spot.

Share this post


Link to post
Share on other sites
Thanks for the speedy replies!

Wow, the Win32 API sucks. Now I remember why I swore never to touch it again a long time ago.

Anyway, I just renamed the function from 'SendMessage' to 'AddMessage' (because, apparently, 'PostMessage' was also used by Win32 [razz]) and that fixed it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
for all your renaming needs :D

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://thesaurus.reference.com/search?q=send

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!