# vc2005 link errors and warnings

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

## Recommended Posts

I have a class MetaScript with the following member function: GetClassInfo which takes a const char* now when i compile it seems to be spitting out a lot of __w64 warnings (ie cast warnings). It looks as though its trying to do a 64bit build? here is the link error: Entity.obj : error LNK2019: unresolved external symbol "public: struct ClassInfo const * __thiscall MetaScript::GetClassInfoW(char const *)" (?GetClassInfoW@MetaScript@@QAEPBUClassInfo@@PBD@Z) referenced in function "public: virtual bool __thiscall ListParser<class Entity *>::Read(struct MetadataTypeInfo const &,void *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class MetaScript *)const " (?Read@?$ListParser@PAVEntity@@@@UBE_NABUMetadataTypeInfo@@PAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAVMetaScript@@@Z) E:\BlackCarbon\Project\QuickGame\Source\Debug\QuickGame.exe : fatal error LNK1120: 1 unresolved externals edit: i should have posted this in the beginner section probably

##### Share on other sites
This is one of the many reasons why #define's are evil. If you take a look at MSDN you'll see that GetClassInfo is infact part of the Win32 API, and like much of the API it uses define's to hide whether or not it's the unicode version of the function. In one of the windows include files there'll be something along the lines of
#ifdef _UNICODE_#define GetClassInfo GetClassInfoW#else#define GetClassInfo GetClassInfoA#undef

In your header file all is well because you haven't included <windows.h> yet, but in your source file you're including <windows.h>, thus every time GetClassInfo appears it gets replaced by one of the above....in particular the definition of that function in your class. If you really need <windows.h> you'll need to #undef GetClassInfo after you include <windows.h>.

If you think this problem could crop up a lot (eg. you regularly include <windows.h> in source files that call MetaScript::GetClassInfo) then you can either have a wrapper header for windows.h that #undef's any problem names (those damned min/max macros come to mind), or just use a different name.

##### Share on other sites
Just looked at this again and realized I got it backwards. You're including <windows.h> in a .cpp file somewhere else that later includes your MetaScript class, thus the instances of GetClassInfo in the header get messed up and the source file is calling MetaScript::GetClassInfoW (instead of MetaScript::GetClassInfo). It doesn't complain at compile time (only link time) because <windows.h> is being included before the header containing the MetaScript class.

• 22
• 10
• 19
• 15
• 14