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

dependency checking

P: n/a
Hi,

Is there already a tool that goes through a C source file and reports
the header files that the source file does not depends on and those
they do?

This becomes handy in a project that has many source and header files
and where changes are frequent.

Thank you.
Wei
Jun 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Weiguang Shi schrieb:
Is there already a tool that goes through a C source file and reports
the header files that the source file does not depends on and those
they do?
This is not on-topic in comp.lang.c.
<OT>
Some compilers and IDEs generate include dependency information,
some improved forms of this; ask in a newsgroup (or whatever is
appropriate) for your compiler/IDE.
Apart from that, have a look at PC-lint/FlexeLint -- it can help
you find unnecessary includes, see for example
http://www.gimpel.com/html/techfaq.htm#q16
</OT>
This becomes handy in a project that has many source and header files
and where changes are frequent.


A project which changes that frequently in its dependencies
likely suffers from bad design.
I am aware that unnecessary includes can clog your source and
have suffered from badly maintained source like that.
<OT>
Back then, it was not very hard to write some script to utilise
the weak dependency information from gcc -- it dumbly tried to
compile source files with one include directive at a time
removed.
</OT>
However, replacing _all_ "superfluous" headers does not work
very well. Consider:
#include "foo.h"
#include "bar.h"
where "foo.h" includes "bar.h" as well and where the original
#include "bar.h"
is intended to give "visible evidence" of that and make sure
that bar.h is included even if foo.h were to change at some
point in the future.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Jun 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.