3 ms·
That reordering is simply a feature of clang-format. Some coding standards require sorting includes alphabetically, possibly to avoid dupes and to make all incl
by TwoBit 7y ago
That reordering is simply a feature of clang-format. Some coding standards require sorting includes alphabetically, possibly to avoid dupes and to make all include usage identical between source files.
- jlarcombe 7y agoIndeed, and one reason I dislike sorting header includes alphanumerically is that it makes it easy for include-order-dependencies between them to creep in, as they're always used in the same relative order.
- dleslie 7y agoIn terms of C/C++ headers, that's like requiring all scopes have their expressions alphanumerically sorted. C/C++ headers are literal code-injection mechanisms; they aren't modifying a runtime environment by importing symbols, they inject code into the compilation unit.
- OskarS 7y ago> Some coding standards require sorting includes alphabetically Those are some pretty dumb coding standards if that's true. (I mean, yeah, the original fault is with the C preprocessor and the fact that header order matters, but since we're stuck with that, having those kinds of coding standards is pretty darn silly!)
- antoinealb 7y agoWell given that the order of the headers matter, wouldn't it make sense to have the coding standard specify one true include order ? That's the only way to have a deterministic result.
- yifanl 7y agoThat ties namespacing to performance, which just sounds horrible to deal with.
- antoinealb 7y agoOf course, the bug is horrible. But given that those type of bugs exist, having a fixed ordering of include statements seem like the least painful way to go.