• Advertisement

Archived

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

Multiple Source Files

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

Why doesn''t any thing work without tweaking for hours? I''ve used multiple source files before and it worked but now I''m working tutorials on www.andypike.com. Im on the fourth one and it uses multiple source files. I have a header that defines some variables and one that defines some functions. To keep them from redefining themselves in multiple source files I use
  
#if !defined(MYHEADERFILE)
#define MYHEADERFILE

//FUnctions and vars

...

#endif

Ive also tried #ifndef and it doesn''t work either. Heres the errors I''m getting
Linking...
main.obj : error LNK2005: "void __cdecl ErrMsg(char *)" (?ErrMsg@@YAXPAD@Z) already defined in CGame.obj
main.obj : error LNK2005: "void __cdecl DxErrMsg(long,char *)" (?DxErrMsg@@YAXJPAD@Z) already defined in CGame.obj
Debug/zbuffer.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.  

Share this post


Link to post
Share on other sites
Advertisement
Not sure why it doesn''t work, but here is how I type it.

#ifndef __MY_HEADER__
#define __MY_HEADER__

.... code ....



#endif // end __MY_HEADER__

Share this post


Link to post
Share on other sites
I tried to place the exact thing you did and it didn''t work, man, this always happens, wasting 5 hours on a problem like this isn''t productive...

Share this post


Link to post
Share on other sites

  • Advertisement