This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Are there some tips to find useless header files?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]