Sign in to follow this  

need helping fixing compilation error in MSVC6.0

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

This topic is 4813 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.

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