Jump to content
  • Advertisement
Sign in to follow this  
rnw159

Multiple Header problem

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

I had been splitting up a large main file into multiple smaller files when I found out that you couldn't include the same header twice anywhere. This is a problem for me because I often need to reuse code and functions all over the place and its a bit hampering to have to only use those functions in one cpp file. Often I will have to include the header in the man then later realize I need to use the functions in another file but will be unable to.

Please, does anyone have any way to work around this problem and reuse functions in different files.

Share this post


Link to post
Share on other sites
Advertisement
Include guards don't let me include a file twice, they stop me from including the same file twice. I still get the error for not knowing what the function is.

Share this post


Link to post
Share on other sites
Then you might want to post actual code giving you errors and the actual errors. There's only so much we can do when you just say stuff doesn't work.

Share this post


Link to post
Share on other sites
<source>

//header 1

class{/*important data*/};

//file 2

#include "header1"

/*function that uses that data*/

//file 3
#include "header1"

//needs to use important data.
</source>


How do I get to use the header 1 data to be used in 2 different files.

Share this post


Link to post
Share on other sites
My actually code is way to long. You don't need to know the specifics, just the basic idea. The code I posted before would give multiple included errors.

What would you do to use data from a header file in multiple cpp files?

Share this post


Link to post
Share on other sites
The code you posted doesn't have include guards and wouldn't compile because you didn't give the class a name.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!