3 ms·
It is by convention that C/C++ headers rely on preprocessor state to determine what blocks to reveal, macros to use, et al. It is quite common to have an auto-
by dleslie 7y ago
It is by convention that C/C++ headers rely on preprocessor state to determine what blocks to reveal, macros to use, et al.
It is quite common to have an auto-generated configuration header, for instance; or a precompiled header; or optional headers that, when present, mutate the behaviour of other headers.
Every time you run a configure script for a C project there's a good chance you're interacting with code in this way.
- lorenzhs 7y agoYeah, and if you want to use clang-format include reordering in such a project, you should read the docs for clang-format's "IncludeCategories". It allows you to separate your includes into blocks by providing regexes and associated priorities. Alphabetic sorting is done only within a block. It's not like clang-format was written by idiots who never used the language before. Maybe read up on what the tool actually does before you get all mad at them?
- dleslie 7y agoI'm not mad? I think it's a harmful anti-feature that's worthy of criticism.
- glandium 7y agoclang-format still allows some ordering when the SortIncludes feature is enabled. Search for IncludeBlocks in https://clang.llvm.org/docs/ClangFormatStyleOptions.html https://clang.llvm.org/docs/ClangFormatStyleOptions.html