Tried to save all changes into the project-specific settings, but here are the most notable options:
- Editor | Code Style | C/C++ | General
- C/C++ formatting engine:
ClangFormat
- C/C++ formatting engine:
- Editor | Code Style | C/C++ | Syntax Style
- Sort include directives:
checked
- Type of slashes to use in include directives:
Use forward slashes
- Use angle brackets instead of quotes:
When possible
- Sort include directives:
- Languages & Frameworks | C/C++ | Order of #includes
- Only
Preserve existing #include groups during a sort
is checked - Added
^<MyLib.*>
just above the^<.*
(thus, below theHeader for the current file
)
- Only
- Optionally Tools | Actions on Save
- Reformat code:
checked
- Reformat code:
A minimal clang-format
file is present with the same include sorting options.
The issue
- Open
B.cpp
- CLion warns that the includes are out of order (
A.h
should be beforeB.h
) - Sort the includes via the context action
MyLib/A.h
is sorted beforeMyLib/B.h
- If reformat code on save is enabled, the clang-format immediately sorts it back to the correct
MyLib/B.h
thenMyLib/A.h
order