Header inclusion ordering style addition
Tanous, Ed
ed.tanous at intel.com
Wed Aug 29 16:50:54 AEST 2018
>
> There is certain case that a header file is expected to be included before
> others, e.g. config.h generated by autotool shall be included before other
> local header files, to ensure that the configs are correctly defined.
> E.g.
>
> #include "config.h"
> #include "bar.hpp"
>
> Will clang-format re-format the order on the above case? If yes, I have
> concern that it could introduce issues, e.g. compile error about undefined
> symbols.
> If clang-format handles it well, it's great!
If clang-format is told to operate this way, it will. It uses regex matched "priorities" then falls back to alphabetical. If config.h needs to be first, it just needs to be put in the appropriate spot in the .clang-format file that everyone uses.
I agree with the other sentiments that so long as it's done via clang-format, feel free to impose whatever header order is desired.
More information about the openbmc
mailing list