Re: [RFA]: Remove unused header files.

J.T. Conklin
2001-03-06T13:02:00Z

>>>>> "Andrew" == Andrew Cagney <ac131313@cygnus.com> writes:
>> I'm unsure about the correct way to handle those are. As long as
>> errno.h is included in defs.h, I see no reason to include it in any
>> *.c file. One could argue that errno.h should be remove from defs.h,
>> but since errno (or the E* macros) is used in almost every file, I
>> suspect we'd have to #include it in many files.

Andrew> I'm aware of two strategies:
Andrew>
Andrew> o Every module include a
Andrew> single header file and
Andrew> that suck in all the other
Andrew> header files.

I've seen this technique used for small systems and it works well ---
that is until it grows into a medium sized or large system. By then,
the effort to convert to a sane include convention is so large it may
never get done. IMO GDB is far beyond the size where this could work.

Andrew> o Every module define their
Andrew> own header and each component
Andrew> pull in the header files it
Andrew> is using.
Andrew>
Andrew> A variation on this theme has
Andrew> each of these header files
Andrew> [not] sucking in anything they
Andrew> refer to.

I'm in favor of this approach, including the variation where header
files include the headers containing any macros, declarations, etc.,
they refer to. I've seen cases when this is not true, where a header
must be included before another because of some implementation detail
rather than a public interface. When the implementation changes, the
header is no longer needed; but then all the source files need to be
updated. This never seems to happen.

Andrew> To get back to your question. I expect the status quo to
Andrew> largely remain:
Andrew>
Andrew> o defs.h provide declarations for
Andrew> the things that all of GDB uses.

I agree. I do think there could be some culling of declarations in
defs.h to module specific headers.

Andrew> o module headers try to be largely
Andrew> self contained. If they refer to other
Andrew> headers then suck those headers in.

Again I agree.

In the absense of any objections, this sounds like this is a beginning
of a include convention.

Andrew> So <errno.h> should be included but (to give a counter example)
Andrew> <endian.h> should be given the boot (see TODO file for details).

So if we agree that <errno.h> should be included in defs.h, there is no
reason why it should not be removed from all the *.c files that include
defs.h.

--jtc