Jump to content
  • Advertisement
Sign in to follow this  
Plasmarobo

Header files

This topic is 3719 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 noticed recently that I have a habit of Declaring and Defining my code entirely in header files. It's easier, but I have run into a few problems with it (multi-level includes...) however, in the main I have fairly linear include trees (not quite sure if that's the right word there). Anyway, my question is: Aside from being a bad habit, is there anything seriously wrong with saving time (and making code more readable/accessible) by just defining everything in the header file? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Let's say you need to use function foo() in multiple files. If you need to use foo() in multiple files, you'll need to include foo.h in every file that uses foo. The code for foo() will be generated seperately for each file that uses foo(). This bloats your executable.

Further, if you change foo() every file that uses foo() must be recompiled! This may not be an issue with small projects, but it rapidly becomes a pain with larger projects.

Edit: I figured someone would beat me with that link.

Share this post


Link to post
Share on other sites
Yeah, I remember feeling vaguely bad about doing it. I guess the truth is I am far too lazy to write out all my methods in a source file.
Thanks guys.

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!