public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Are there some tips to find useless header files?
@ 2005-05-21 16:09 gan_xiao_jun
  2005-05-23 16:02 ` Eljay Love-Jensen
  2005-05-23 16:40 ` Lionel B
  0 siblings, 2 replies; 3+ messages in thread
From: gan_xiao_jun @ 2005-05-21 16:09 UTC (permalink / raw)
  To: gcc-help

Are there some tips(script or command lines) to find
useless header files in c or cpp files?

For example:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
#include <useful1.h>
...
#include <useless.h>//<===how to find it by script
...
#include <useful2.h>

main()
{
...
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Thanks in advance
gan


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Are there some tips to find useless header files?
  2005-05-21 16:09 Are there some tips to find useless header files? gan_xiao_jun
@ 2005-05-23 16:02 ` Eljay Love-Jensen
  2005-05-23 16:40 ` Lionel B
  1 sibling, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2005-05-23 16:02 UTC (permalink / raw)
  To: gan_xiao_jun, gcc-help

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Are there some tips to find useless header files?
  2005-05-21 16:09 Are there some tips to find useless header files? gan_xiao_jun
  2005-05-23 16:02 ` Eljay Love-Jensen
@ 2005-05-23 16:40 ` Lionel B
  1 sibling, 0 replies; 3+ messages in thread
From: Lionel B @ 2005-05-23 16:40 UTC (permalink / raw)
  To: gcc-help

<gan_xiao_jun@yahoo.com> wrote in message news:20050521160448.54635.qmail@web53907.mail.yahoo.com...
> Are there some tips(script or command lines) to find
> useless header files in c or cpp files?

I recall there was an interesting (if inconclusive) thread on this in comp.lang.c++ recently:

http://groups-beta.google.com/group/comp.lang.c++/browse_frm/thread/3f5cad33e4c765a5/87525506d2f11c25

-- 
Lionel B


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-05-23 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-21 16:09 Are there some tips to find useless header files? gan_xiao_jun
2005-05-23 16:02 ` Eljay Love-Jensen
2005-05-23 16:40 ` Lionel B

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).