[kwlug disc.] static code checker for detecting unreferenced
header files?
Robert P. J. Day
rpjday at mindspring.com
Sun Mar 11 17:24:26 EST 2007
On Fri, 9 Mar 2007, Ilguiz Latypov wrote:
>
> On Fri, Mar 09, 2007 at 02:01:20PM -0500, Robert P. J. Day wrote:
> > is there a static code checker for scanning a directory structure of
> > C/header files and detecting header files that are simply not being
> > included from *anywhere* in the tree?
>
> Perhaps, the -M... options of gcc will let find and filter out all
> referenced header files?
>
> SCons has a C/C++ preprocessor, or "scanner". I wonder if its code
> can be reused to find orphaned header files?
i'll take a look at both of those, but i'm not sure they're going to
quite fit the bill. not surprisingly, i wanted to scan the kernel
source tree looking for "dead" header files -- header files that are
no longer included *anywhere*, probably because old source was dropped
but some of the corresponding header files were overlooked.
as a first pass, i wrote a brutally simple shell script that simply
collected the basename of every header file in a specified
sub-directory, then scanned the entire tree trying to find some
reference to *any* header file with that basename. like i said,
brutally simple, and guaranteed to miss at least a few unused files.
but it's a start.
i'm not sure how gcc with "-M" would solve this, but i'll look at it
more closely when i get a few minutes.
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
More information about the KWLUG-Disc
mailing list