By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,908 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,908 IT Pros & Developers. It's quick & easy.

Tool to analyze header dependencies & eliminate redundancy

P: n/a
We have a mature project that suffers long build times because many
modules pull in far more than they need. In the long term I would like
to refactor to break some of the dependencies, but I would like to
start by eliminating unneeded header includes. Is there a tool that
can parse a set of source files and identify redundancies?
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Tue, 19 Jul 2005 19:20:37 -0700, Code4u <co****@gmail.com> wrote in
comp.lang.c++:
We have a mature project that suffers long build times because many
modules pull in far more than they need. In the long term I would like
to refactor to break some of the dependencies, but I would like to
start by eliminating unneeded header includes. Is there a tool that
can parse a set of source files and identify redundancies?


Redundancies should be limited by include guards, or perhaps
implementation-specific options that some provide that prevent even
opening the file a second time to get to the header guard.

As for a tool that detects unnecessary inclusions, PC-Lint
(www.gimpel.com) does an excellent job of that in C code. They claim
to do so in C++ as well, but I haven't verified that as extensively as
I have with C.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 23 '05 #2

P: n/a
Code4u wrote:
We have a mature project that suffers long build times because many
modules pull in far more than they need.
Most large C++ projects make that mistake.
In the long term I would like
to refactor to break some of the dependencies, but I would like to
start by eliminating unneeded header includes. Is there a tool that
can parse a set of source files and identify redundancies?


g++ has a compiler switch that prints all included files of a given
source file. 'makedepend' also finds out include dependencies. You can
analyze the output with a hand-written tool.
AFAIK, no tool is available that tells you which #includes can be
changed to forward declarations. BTW, before you start you need to read
Lakos 'Large-Scale C++ Software Design'.

Jul 23 '05 #3

P: n/a
Also check if your project supports precompiled headers.

grep for #include within your .h files

Create a dependency file (makedepends or if Visual Studio export
makefile with dependencies). Scan this manually or with a script to
find heavily used include files.

Stuart

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.