News for hackers. Stuff that matters.
Re:Clang Format Tanks Performance by daemin on Wednesday November 20, 2019 @08:34AM (#21583727)
One other ordering I've encountered which helps remove errors is to list the headers in reverse generic order. Meaning that you go from the most specific header files to the least specific. So <algorithm> and <windows.h> would be getting included last.

This helps ensure that your specific project level header files have all the necessary forward declares and includes to be a fully functioning and complete header.

Re:Clang Format Tanks Performance by craftinator on Wednesday November 20, 2019 @08:15PM (#21590527)
I also sort my includes this way. The trouble is, determining how generic an include (inclusion?) is is a fuzzy problem. Sometimes I get stuck trying to figure out which header is more abstract, and at times I've run into side effects like this even with reverse generic sorting.
Re:Clang Format Tanks Performance by daemin on Thursday November 21, 2019 @06:03AM (#21593014)
Yeah, this header sorting is only meant to be a tool to help craft header files which are independent. If that's not your project structure then you can use whatever sorting you want.

In the end though you'll have to make a decision on how to sort the projects and which one is more or less specific than another. Kind of like deciding to just sort by pointer address if all else is equal.