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

Andrew C Aitchison andrew at aitchison.me.uk
Thu Nov 24 01:55:41 PST 2022


On Thu, 24 Nov 2022, ElPaso wrote:

> Hi,
>
> Motion:
>
> Adopt RFC88: RFC69 C/C++ Code Formatting [1]
>
> I have updated the RFC [1] to use pre-commit and I have created a draft 
> implementation of the pre-commit hook and the CI integration with a GH 
> workflow [2].
>
> If adopted, we still have to agree on which coding style to apply (for now I 
> used a clang-format file I've found under gdal/scripts), but the biggest 
> decision is wether proceed with an initial "Big Reformat" or an incremental 
> one, my draft implementation supports both.
>
> Kind regards.
>
> [1] 
> https://github.com/elpaso/gdal/blob/rfc69_cplusplus_formatting-text-only/doc/source/development/rfc/rfc69_cplusplus_formatting.rst
> [2] https://github.com/elpaso/gdal/tree/rfc69_cplusplus_formatting_revival

I have just tried this on my driver code and am concerned that the
default sets --sort-includes.

man md5 suggests
 	#include <sys/types.h>
 	#include <md5.h>

but on Ubuntu 22.10/kinetic

>clang-format-11 --version
Ubuntu clang-format version 11.1.0-6build1
>cat include_md5.cpp
#include <sys/types.h>
#include <md5.h>
>clang-format-11 include_md5.cpp
#include <md5.h>
#include <sys/types.h>
>
>clang-format-11 --sort-includes=FALSE include_md5.cpp

#include <sys/types.h>
#include <md5.h>
>

So without tweaking, clang-format is potentially breaking my code.
I fear that we need a project .clang-formats file with atleast
SortIncludes:    false

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


More information about the gdal-dev mailing list