Archived

This topic is now archived and is closed to further replies.

Include guards

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

My compile spits out the following error messages when in build my project: --------------------Configuration: GameDevelopment - Win32 Debug-------------------- Compiling... bubbles.cpp Linking... TGALoader.obj : error LNK2005: "unsigned char * cTGAcompare" (?cTGAcompare@@3PAEA) already defined in bubbles.obj TGALoader.obj : error LNK2005: "unsigned char * uTGAcompare" (?uTGAcompare@@3PAEA) already defined in bubbles.obj TGALoader.obj : error LNK2005: "struct TGA tga" (?tga@@3UTGA@@A) already defined in bubbles.obj TGALoader.obj : error LNK2005: "struct TGAHeader tgaheader" (?tgaheader@@3UTGAHeader@@A) already defined in bubbles.obj Debug/GameDevelopment.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. Creating browse info file... GameDevelopment.exe - 5 error(s), 0 warning(s) I have used include guards on all my headers, so i dont see what the problem is. Any ideas? Edited by - executor_2k2 on January 28, 2002 12:35:56 AM

Share this post


Link to post
Share on other sites
The keyword ''extern'' tells the compiler that the variable exists but is defned somewhere else (i.e. has external linkage). Thus you put ''extern unsigned char * cTGAcompare'' in a header file as a declaration, and stick ''unsigned char * cTGA compare'' in ONE of the appropriate source file as a definition.

''tis the same as with class statics.

Share this post


Link to post
Share on other sites