CLion add automatically include file without my confirm
Answered
CLion 2023.1.3
In Mac,
for example,
if i want to use "uint8_t" on my project ,i type "uint8_t" ,then clion hint:

then i chose first selection. What bother me is clion add automatically a include file in my project without my confirm:

i don`t want use this file, this file belong MacOS,my project is supposed to run on Linux.However, my project is also include the file that contain "uint8_t".How to close this Automatic addition.
Please sign in to leave a comment.
Hello!
>How to close this Automatic addition.
Go to `Preferences | Editor | General | Auto Import` and disable `C/C++ | Auto import in completion`.
>my project is supposed to run on Linux
Generally, in such cases it's better to use a proper toolchain (a Linux one) so that smart code features can work correctly. It can be a "Remote Host" toolchain or a Docker toolchain depending on where you build the project.
Is this option no longer available for C/C++? I cannot find it in my CLion 2025.1.3 settings. I would really like to disable it, because a lot of the times I am getting compiler errors due to auto-generated includes.
Alex Petenchea, most probably, the ReSharper C++/Rider C++ language engine is enabled in your CLion - https://www.jetbrains.com/help/clion/clion-nova-introduction.html.
For the Nova engine, the settings related to auto-import are located in other places (see CPP-35360). You can disable the following options:
File | Settings | Languages & Frameworks | C/C++ | General>Show popupsfor import actions(if you disable this option, imports will only be suggested when you explicitly useAlt+Enter)File | Settings | Editor | General | Code Completion>Show import items in basic completion(disables auto-import during code completion)File | Settings | Editor | General | Code Completion>Add #include after completion of member of incomplete classIndeed, I have the ReSharper engine enabled.
I applied your suggested settings, thank you!
I am on the latest version and disabling the suggested settings won't change anything for me. Has anything changed? Or, should I open a bug report?
Hello,
To understand and address the question, please share with me the current behavior with the disabled pop-up suggestions, and your expectations.
Hello Sergey,
Here's an example with screenshots, it does not matter which combo of the suggested settings I try. Results are the same.
Here's a real-world project. Please notice I do not have <iostream> included. When I type std::cout it makes suggestions.
I press Tab and it adds <iostream> automatically:
I do not personally like this feature, whether I copy/paste code or type, or use autocomplete, I do not want it to include headers. I have clang-tidy and IWYU setup and these kind of things are getting caught by those, but the IDE assumes I need it. I do not, since I might remove the code and many times it includes wrong headers that should not be there.
Hope that clarifies it.
I've noticed in my screenshot it also included <ostream> as well after pressing Tab.
Hello,
Thank you for the information.
I see this issue is also being investigated in CPP-50287.
Please wait for the further updates there.