Archived

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

compiler question Visual c++

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

Does anyone knows how to keep the compiler from including multiple header files. Example I am making a game. And instead of programming eveything on one cpp file. I made header files and the corrosponding cpp file. I included the header files in to all of the files. But then I get a erro meassge saying lnk 2005 error: My best guess is that I put in the same header files into each cpp document. And the compiler is reading it as me trying to make the same thing twice. Is the a way to tell it that I only want to use a header file once?

Share this post


Link to post
Share on other sites
If you arn''t worried about cross platform compatibility, then stick


#pragma once


at the top of all your header files.

If you are worried about cross platform compatibility, then use inclusion guards, which are like this:


#ifndef _SOME_IDENTIFIER_SPECIFIC_TO_THIS_HEADER_
#define _SOME_IDENTIFIER_SPECIFIC_TO_THIS_HEADER_

//Header code goes here

#endif

Share this post


Link to post
Share on other sites