dependency checking

Discussion in 'C Programming' started by Weiguang Shi, Jun 21, 2006.

  1. Weiguang Shi

    Weiguang Shi Guest

    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
    Weiguang Shi, Jun 21, 2006
    #1
    1. Advertising

  2. Weiguang Shi

    Michael Mair Guest

    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.
    Michael Mair, Jun 21, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    17
    Views:
    10,995
    Tim Hubberstey
    Apr 6, 2005
  2. danpres2k
    Replies:
    0
    Views:
    1,459
    danpres2k
    Aug 13, 2003
  3. sowbug
    Replies:
    0
    Views:
    411
    sowbug
    Aug 19, 2003
  4. Karsten Wutzke
    Replies:
    3
    Views:
    3,091
    Dale King
    Jun 5, 2005
  5. Alex Hunsley
    Replies:
    0
    Views:
    369
    Alex Hunsley
    May 3, 2006
Loading...

Share This Page