6

Are there any tools which parse .h files and recommend the removal of #includes. For example if the defines in the include are not being used or if it is possible to do a forward declaration instead.

I work on both windows and linux platforms.

Baz
  • 12,713
  • 38
  • 145
  • 268
  • 1
    possible duplicate of [C/C++: Detecting superfluous #includes?](http://stackoverflow.com/questions/614794/c-c-detecting-superfluous-includes) – interjay Nov 06 '12 at 13:18
  • This isn't a 'tool' but.. generally you won't have too many includes - you could just do it manually! comment out, compile - if it fails keep it otherwise remove it and then repeat. – Mike May 16 '14 at 12:52
  • a good answer to a similar question can be found here: https://stackoverflow.com/a/615057/7717505 – helmken Apr 03 '18 at 18:20

3 Answers3

4

include-what-you-use is intended to do this.

John Bartholomew
  • 6,428
  • 1
  • 30
  • 39
2

ReDHead is a project for exactly that. It's an Eclipse plug-in.

Kos
  • 70,399
  • 25
  • 169
  • 233
2

I was looking for such tool some time ago and I now found out that this functionality is also provided by Resharper C++ plugin for Visual Studio.

Tomasz Kal
  • 119
  • 9