clang-format keeps the blocks independent, yes. We usually divide in three (or more) blocks: internal headers, third party, std. But it is a matter of taste, of course. This is the example of a file that uses gdal:
#pragma once #include "CommandOptions.h" #include <gdal_priv.h> #include <gdal_utils.h> #include <ogr_feature.h> #include <ogr_spatialref.h> #include <ogrsf_frmts.h> #include <memory> #include <stdexcept> Some includes may have special conditions. Then just use blocks to keep things in order. Also aesthetic order. Or use // clang-format off/on to not order something that is very special. Anyhow, all this is a mater of taste. But I am really happy when the file is automagically nicely formatted just when I save it. .___ ._ ..._ .. . ._. .___ .. __ . _. . __.. ... .... ._ .__ Entre dos pensamientos racionales hay infinitos pensamientos irracionales. On Thu, 24 Nov 2022 at 20:34, Andrew C Aitchison <and...@aitchison.me.uk> wrote: > 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 > and...@aitchison.me.uk > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/gdal-dev >
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev