[OT] Identifying unused include directives?
Russ Allbery
rra@stanford.edu
Sun Aug 31 03:27:00 GMT 2003
Robert Dewar <dewar@gnat.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 (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
More information about the Gcc
mailing list