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: [PATCH, RFC] plugin to warn about surplus includes


>>>>> "Bernhard" == Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> writes:

Bernhard> - should handle structs.

There are some other difficult cases.

First, don't let this discourage you :-).  I think this would be a
useful feature.

I think in general you cannot actually ever tell if a header is unused
or not.  Maybe it will only be used with some set of -D options, or when
some configure option is passed in.  So I think users of a plugin like
this will always have to live with some "false" reporting.

A header can #define things that are used by other headers.  You would
need to modify libcpp to detect this situation.

Suppose a system header which is used includes a header which is not
used.  In this case, I think a warning about the inner header should be
suppressed -- users generally can't do anything about this.  (There are
other worse cases like this.  You might have a system header that seems
directly unused, but it is the documented way to access some set of
declarations.  E.g., <stdio.h> might actually just be a bunch of
#includes.)

Tom


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