Skip to main content
GameDev.net gamedev.net
🔒 Locked

need helping fixing compilation error in MSVC6.0

Started by Axenation Oct 11, 2004 at 4:46 AM 1 replies 1.3k views
Original Post
Axenation
Axenation
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.
Now I get a cookie!
Axenation
Axenation
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
Now I get a cookie!
Kippesoep
Kippesoep
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.
Kippesoep

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.