This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Are there some tips to find useless header files?
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: gan_xiao_jun at yahoo dot com, gcc-help at gnu dot org
- Date: Mon, 23 May 2005 11:01:15 -0500
- Subject: Re: Are there some tips to find useless header files?
- References: <20050521160448.54635.qmail@web53907.mail.yahoo.com>
Hi gan,
>Are there some tips(script or command lines) to find useless header files in c or cpp files?
Interesting challenge!
I recommend using Perl to parse the header files specified in your C++ source file, and maintain a set of the identifiers declared (including #define'd) in that header file. Note: your choice whether or not to dive into header files included by header files (i.e., header files included indirectly).
Then make a map of all the identifiers in your C++ source file.
Then have Perl "check off" each one of those identifiers in your C++ source file, and note which header file it came from (thus marking that header files as "useful").
When finished, print a list of all the header files that are not marked as "useful".
And maybe also print a list of all identifiers that are orphans in your source file. Might be indicative of a missing header file, or a header file that was included indirectly.
Voila!
HTH,
--Eljay