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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux