Jump to content
  • Advertisement
Sign in to follow this  
Axenation

need helping fixing compilation error in MSVC6.0

This topic is 5032 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

error C2039: 'GetClassNameA' : is not a member of 'CPlayer' ok i have a CParty class that looks kinda like this
class CParty
{
  CPlayer* m_player[4];

  public:
  CPlayer* GetPlayer(Uint8 index)
  {
    return m_player[index];
  }
};


and a CPlayer class that looks kinda like this
class CPlayer
{
  Uint8 m_class;

  public:
  char* GetClassName()
  {
    static const char className[6][8] = 
    {
      "ClName1",
      "ClName2",
      "ClName3",
      "ClName4",
      "ClName5",
      "ClName6"
    };
    return (char*)className[m_class];
  }
};


ok now the actual error is comming from another file with this line in it. NOTE: m_party is a pointer an instance of class CParty.
m_font->print(screen, m_party->GetPlayer(0)->GetClassName(), 32, 40);


notice how i make a call to CPlayer::GetClassName(), but in the error report the function name is a little bit fudged to GetClassNameA instead of GetClassName.

Share this post


Link to post
Share on other sites
Advertisement
nevermind, it was a compiler error that i fixed.

i changed the declaration of CPlayer::GetClassName() to CPlayer::GetClassNameA()
then it compiled correctly and ran fine.

then changed the declaration back to the original, then compiled it and it ran fine.

so i guess this is why most people have upgraded from MSVC6.0

Share this post


Link to post
Share on other sites
It's not a compiler error. It's caused by the windows headers. Windows has a function called "GetClassNameA" to retrieve a window class name in ASCII mode and "GetClassNameW" to retrieve a windows class name in Unicode (Widestring) mode.

windows.h or one of the headers it includes has something along the lines of:

#ifdef _UNICODE
#define GetClassName GetClassNameW
#else
#define GetClassName GetClassNameA
#endif



So this will happen whatever compiler you use. There is only one solution: do not use method names that match global Windows functions.

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!