Multiple Source Files

Started by
2 comments, last by perfectly_dark 21 years, 9 months ago
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.  
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__
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...
Read Organizing Code Files in C and C++.

---
Come to #directxdev IRC channel on AfterNET

This topic is closed to new replies.

Advertisement