Archived

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

CodeMaster000

Inclusion Error in VC++

Recommended Posts

CodeMaster000    122
I though some variables into a header file that I call many times. The header file has inclusion guards on it and yet it keeps saying 3 times the object are allready declared. I had this problem before but I forgot the trick to fix it. Can someone help.

Share this post


Link to post
Share on other sites
BlueDev    126
Yes one thing is you might have multiple cpp, c and or .h files that somehow include the header file more than once, best thing I can recommend is to check all your source files to see if you find a header file declared more than once.

- BlueDev

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Well, if I guess right, then you are defining objects in the header file. This should be avoided. Rather, declare your objects as extern in the header and define them properly in one of your .cpp files.

Share this post


Link to post
Share on other sites
CodeMaster000    122
How can I use the same variables in different cpp files? Should I put them in a header or is the a command where I can declare them in each cpp file without having each decloration taken seriously?

Share this post


Link to post
Share on other sites