Jump to content
  • Advertisement

Archived

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

dcosborn

C++ nested includes

This topic is 5413 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''ve got a number of header files that include other headers. If a source file requires one of these headers along with a header which the aforementioned header includes for itself, should I bother explicitly including that second header in the source file? Thus far I''ve always assumed no. But what if the first header was changed and no longer included the second header? The source file would still need it and would have to be changed as well. I''m starting to think this is bad because it increases maintainance work and makes dependencies more intricate. Any thoughts? -Dave

Share this post


Link to post
Share on other sites
Advertisement
You''re thinking right. To prevent errors due to changes made to header files in the future, you should include all headers directly needed by the source file, and not depend on the includes of the other header files.

Just pretend that you don''t know what the other header files include, and just include what you know the source file needs.

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!