This is the mail archive of the gcc@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: [OT] Identifying unused include directives?


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/>


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