This is the mail archive of the
mailing list for the GCC project.
Re: [OT] Identifying unused include directives?
- From: Russ Allbery <rra at stanford dot edu>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 30 Aug 2003 10:56:58 -0700
- Subject: Re: [OT] Identifying unused include directives?
- Organization: The Eyrie
- References: <20030830162553.0982BF2DFE@nile.gnat.com>
Robert Dewar <email@example.com> writes:
> Yes, that sounds like a reasonable definition, although the only
> practical way of having the compiler test this would be to compile with
> and without each #include.
Given that this is the sort of thing that one could reasonably run
periodically on one's entire source base, I'm not sure that's necessarily
a bad way of approaching it. It seems like one could write a small
program to do this without changing gcc at all; it probably wouldn't
handle the edge cases for include via preprocessor abuse, but for the
common case it wouldn't be particularly difficult.
It would be slow, but it's the sort of thing one could run overnight and
then look at the results later. It's not like there's generally much
urgency to removing unnecessary includes.
One difficulty in applying this to a practical problem is that the set of
necessary includes frequently varies by platform.
Russ Allbery (firstname.lastname@example.org) <http://www.eyrie.org/~eagle/>