Jump to content
  • Advertisement
Sign in to follow this  
Prozak

Tool to certify Includes are necessary

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

Didn't know exactly where to put this... Is there a tool that will read up your code and: 1) Create a list of unused variables (I know VS already does this in the form of a warning) 2) Create a list of unnecessary #includes, source code that #includes other files, but that #include is not necessary... What other code-cleaning tools do you guys use?

Share this post


Link to post
Share on other sites
Advertisement
For #2 I'm very high-tech about it. My methodology consists of:

"WTF is this being included for?"
Comment it out.
Try to compile.

Share this post


Link to post
Share on other sites
You forgot some steps Anon Mike:

"WTF is this being included for?"
Comment out #include<MyClass>.
Try to compile.
Doesn't compile
Add in header "class MyClass";
Try to compile again.

Share this post


Link to post
Share on other sites
I think it's important to include everything that is directly required by a header or source file - you shouldn't depend on a particular header to include another that you also need, unless you're sure that your program structure isn't going to change in the future.

If you use a windows type (HWND, WPARAM etc) anywhere in the file, include windows.h (unless the source file's header includes it). If you're using MyClass, include MyClass.h.

Removing headers just because your program would still compile afterwards is a step towards losing your sanity.

Share this post


Link to post
Share on other sites
I know that for java, a tool like this exists for NetBeans and its great, but unfortunately, I don't know of an equivalent for c++. Would make life easier though, wouldn't it?

Share this post


Link to post
Share on other sites
Quote:
Original post by Wavarian
I think it's important to include everything that is directly required by a header or source file - you shouldn't depend on a particular header to include another that you also need, unless you're sure that your program structure isn't going to change in the future.

If you use a windows type (HWND, WPARAM etc) anywhere in the file, include windows.h (unless the source file's header includes it). If you're using MyClass, include MyClass.h.

Removing headers just because your program would still compile afterwards is a step towards losing your sanity.

I agree. This is how I handle #includes.

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!