dependency checking

W

Weiguang Shi

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
 
M

Michael Mair

Weiguang said:
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
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top