7

In order to reduce unnecessary coupling and decrease compilation time, is there a tool which can help locate (and perhaps interactively remove) unnecessary inclusion of header files in C/C++ translation units?

In particular, a tool that can detect, for every translation unit, all those types whose #include directives can be replaced with forward declarations, in the context of that translation unit.

If this is not achievable, do useful approximations exist?

Technophile
  • 425
  • 6
  • 9
nyarlathotep108
  • 4,663
  • 1
  • 16
  • 46
  • 2
    Duplicate of this question - http://stackoverflow.com/questions/614794/c-c-detecting-superfluous-includes ? – Neil Feb 25 '16 at 16:39
  • `#include` is a *directive,* not a *macro.* – fuz Feb 25 '16 at 16:41
  • 1
    @Neil the question is not exaclty the same (that guy is asking for completely unused includes removal), but the most voted answer actually talks about forwards declarations also. So, thanks. – nyarlathotep108 Feb 25 '16 at 16:53
  • I suppose you want to _decrease_ the compile time. These kind of "optimisations" are useless, you wont get a significant decrease in compile time with tweaks like that. – Jabberwocky Feb 25 '16 at 18:44
  • @nyarlathotep108 why do yu think this will decrease compile time? – Jabberwocky Feb 26 '16 at 15:27
  • @MichaelWalz The translation units become exponentially bigger if there is no control over the #include directives, and so also the compilation time is affected by it. – nyarlathotep108 Feb 26 '16 at 15:33
  • @nyarlathotep108 you should clarify your question or ask another question with a more precise description of what exactly you want and why. – Jabberwocky Feb 26 '16 at 15:35
  • 1
    @MichaelWalz edited, hope it is more clear – nyarlathotep108 Feb 26 '16 at 17:13

0 Answers0