[gdal-dev] SortIncludes was Re: Motion: adopt RFC69 C/C++ Code Formatting

Andrew C Aitchison andrew at aitchison.me.uk
Thu Nov 24 11:34:21 PST 2022


On Thu, 24 Nov 2022, Javier Jimenez Shaw wrote:

> In my opinion if the order of the includes affects the output there is
> something wrong in the code. I hope md5 is not recommending the order.

It turns out that although 'man md5' says:
      #include <sys/types.h>
      #include <md5.h>

the header file /usr/include/md5.h includes <sys/types.h> very early,
so there is no actual problem, at least on this platform - Ubuntu 
22.10/kinetic.

> In case you insist on keeping the order defined by the user
>  ... you can just add a newline to separate the includes in blocks.
> Clang-format keeps the contiguous blocks independent.

There are times when setting environment variables changes the
effects of a header, so it is a relief to hear that clang-format
wont reorder includes around that.

I find it interesting to note that, by default, flake8 wants python code
to put 'Stdlib' and 'Third Party' imports to be in separate groups,
whilst clang-format wants to sort
   #include <>
and
   #include ""
into one alphabetical list.

-- 
Andrew C. Aitchison                      Kendal, UK
                    andrew at aitchison.me.uk


More information about the gdal-dev mailing list