Jump to content
  • Advertisement

Archived

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

boolai

compiler question Visual c++

This topic is 5692 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
Advertisement
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
Thanks so much. I was reading c primer. But still did not get it. Sometimes you just have to ask for clarification.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!