home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!swrinde!elroy.jpl.nasa.gov!news.claremont.edu!ucivax!megatek!tomw
- From: tomw@stephanie.megatek.uucp (Tom Wright)
- Newsgroups: comp.lang.c
- Subject: need tool to eliminate unused #include's
- Message-ID: <1992Aug14.170926.6875@megatek.uucp>
- Date: 14 Aug 92 17:09:26 GMT
- Sender: tomw@megatek.uucp (Tom Wright)
- Organization: Megatek Corporation, San Diego, California
- Lines: 30
-
- Over time, programmers tend to add #include's but never remove them,
- regardless of if they're still needed. It's just too difficult to see
- if they're still needed. Ultimately, in a large system, this causes
- 'make' or 'Imake' to do many needless recompiles if dependencies are
- used. Not using dependencies causes many wasted hours of looking for
- bugs that aren't really there.
-
- Does anyone know of a tool that figures out if any of the #include's
- in a module are no longer needed?
-
- It has been suggested that one could selectively remove #include's and
- try recompiling and looking for no errors, but this is unsatisfactory
- in that the use of -D on the compile command line could make an #include
- that had appeared unneeded in a previous compile now become needed.
-
- I imagine the tool would have to build a list of each thing that I'll
- call a symbol that is defined in a #define, a typedef, or a struct (or
- a few other things I haven't thought of yet) and which .h it's defined
- in (ignoring #ifdef's and #ifndef's). Then it would have to keep track
- of which .h's they're used in and which symbols they're used in. Ultimately,
- it would check the module source to see what gets used. To create the
- final answer, it would need to check all the symbols in each .h to see
- if any of them were ultimately used in the source or in a .h that had
- a symbol that got used.
-
- Creating such a processor would be non-trivial, but the productivity
- gain could be very large. Does anyone have such a thing?
-
- Thanks,
- Tom
-