[RFC] Sort #includes in gdb

Joel Brobecker brobecker@adacore.com
Sun Jan 27 04:58:00 GMT 2019


> As discussed previously on the list, here is the patch to sort
> includes in gdb.  Include files are put into up to 4 stanzas; stanzas
> are separated by newlines.  The stanzas are:
> 
> 1. For non-header files, the "introductory" headers.  First either
>    defs.h, common/common-defs.h, or server.h, depending on the
>    location of the source file.  Next, if the .c file has a
>    corresponding .h, that .h.  (There is one exception to this rule,
>    thread-iter.c.)
> 
> 2. System header files, which are determined by the use of <> in the
>    include.
> 
> 3. Header files that are part of binutils-gdb but not in the gdb
>    subdirectory -- mostly things coming from libiberty or BFD.
> 
> 4. gdb header files.

It might be FUD on my part, but with C & C++, I've always been very
nervous about changing the order of #include-s. This is because some
headers sometimes define the same macros with different values, and
so order can make a difference for those (without really knowing
which is more correct, if any, and whether we are in fact getting
the one that we should). And of course, this is all highly platform-
dependent.

I really like, however, the idea of overcoming that fear, and
evaluate in practice what the real impact of order is. But since
we are getting close to 8.3 branching, could we hold the actual
puth until after the 8.3 branch is created?

-- 
Joel



More information about the Gdb-patches mailing list