Jump to content
• Advertisement

# vc2005 link errors and warnings

This topic is 4608 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 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 this post

##### Share on other sites
Advertisement
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 this post

##### 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.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 18
• 20
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633363
• Total Posts
3011514
• ### Who's Online (See full list)

There are no registered users currently online

×

## 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!