This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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] Remove duplicate or commented-out #includes


>> It would be possible to sort #includes, or maybe run
>> include-what-you-use on gdb, but I haven't tried that.  I'd be
>> interested to hear if you think this would be worthwhile, thoug.

Gary> I'd consider it worthwhile.  I'd really like sorted #includes.
Gary> Some files have random whitespace in the list too, that maybe
Gary> made sense once.

I wrote a script to sort the includes.  The output is rather voluminous,
not totally sure yet how I will submit it.

It doesn't try to do a 100% job.  For example, some files in gdb include
other files at random spots -- not all includes are at the top of the
file -- and the script doesn't try to handle this.

It did find 40 .h files that don't have include guards.  Maybe I will
try to automatically fix these.

Building revealed a few minor order dependencies in the headers.  I'll
submit this as an initial cleanup.


I chose to have the includes ordered this way:

First stanza:

1. defs.h (or server.h or common-defs.h)
2. for a .c file, the corresponding .h if it exists
   (two exceptions were needed to this rule)

Second stanza (stanzas separated by a blank line) holds system headers.

Third stanzas holds includes of headers in binutils-gdb but not part of
gdb proper.

Fourth stanza is gdb-specific headers.


It's reasonably easy to change this around though.


It would be possible to modify this same script to try removing includes
from .c files and seeing whether the file still compiles.  It would just
take a long time on this machine I have at the moment.

If anyone wants to try it out for themselves, I can send the
instructions.

Tom


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