Organize headers with highest import point/ as specific as possible?
Answered
When I organize included headers with CLion, it seems CLion picks headers that are lower in the header tree and include everything that is required, but also necessarily bring in declarations that are not required. This approach leads to a nice, compact and readable header list.
I dislike this style of import organisation, for three reasons:
- It makes it harder to manually trace to your required declaration when you do not have IDE support.
- It places additional onus on tools for dependency analysis.
- It increases the risk that you will encounter preprocessor programming that you need to understand to analyze what is actually going on.
So please, CLion, can you organize my header imports as much as possible in such a way that I get the most specific headers, even if the list is long?
Please sign in to leave a comment.
Hello! Could you please clarify whether you mean Code | Optimize Imports command?
Yes, I would like additional settings for Code | Optimize Imports to provide this behaviour. I imagine a checkbox that says:
"use most specific header files".
Thank you for the clarification! I've created a feature request in our tracker: https://youtrack.jetbrains.com/issue/CPP-14480. Feel free to comment or upvote in order to get updates.