You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Force includes do not work if compile_commands is used #1842
Hi,
unfortunately the files specified in force includes are ignored if you use compile_commands.json for the include path.
Perhaps you can fix this for future releases.
My config:
VS Code 1.22.1
C/C++ ext 0.16.1
Ubuntu 16.04 x86-64
It looks like this is "by design" -- the forced includes are taken from the compile_commands.json via -include or -FI arguments. Is that not sufficient for some reason?
Sean McManus (@sean-mcmanus) I use a force-include because I need auto-completion on a global object. Since it is global, it is unsure whether the needed includes are present or not. If not, the auto-completion does not work without the forced include. I thought this would be a use case where one could use forced includes? At least it works like a charm when I don't use the compile_commands.json and stick with the manually specified include path.
When you generate the compile_commands.json, it's supposed to add forced includes or whatever else is needed for compilation, therefore it is not expected for users with compile_commands.json to want to add additional forcedInclude paths, which is why we also ignore the includePath and defines. If your source file is not present in the compile_commands.json, then it'll fall back to using the forcedInclude setting.
Sean McManus (@sean-mcmanus) Ok, now I see what you mean... In my case, the forced includes are not needed for compilation at all, so my compile_commands.json does not know about them. I only specified them inside c_cpp_properties.json because they are needed for proper auto-completion inside VSC. I was not aware that this use case could be unusual.
Can you tell us what exactly isn't working for auto-completion? Are system includes/defines missing? If you can share an entry from the compiler_commands.json for a file where things are not working properly, we might be able to figure out if there is a bug elsewhere since you shouldn't need to use forcedInclude with compile_commands.json.
Actually this is a duplicate of my own issue #1699. My issue occurs because IntelliSense is limited to included headers, even with a compile_commands.json where the entry for the respective file includes the folder with the needed header.
Activity
sean-mcmanus commentedon Apr 16, 2018
It looks like this is "by design" -- the forced includes are taken from the compile_commands.json via -include or -FI arguments. Is that not sufficient for some reason?
cylonid commentedon Apr 16, 2018
Sean McManus (@sean-mcmanus) I use a force-include because I need auto-completion on a global object. Since it is global, it is unsure whether the needed includes are present or not. If not, the auto-completion does not work without the forced include. I thought this would be a use case where one could use forced includes? At least it works like a charm when I don't use the compile_commands.json and stick with the manually specified include path.
sean-mcmanus commentedon Apr 16, 2018
When you generate the compile_commands.json, it's supposed to add forced includes or whatever else is needed for compilation, therefore it is not expected for users with compile_commands.json to want to add additional forcedInclude paths, which is why we also ignore the includePath and defines. If your source file is not present in the compile_commands.json, then it'll fall back to using the forcedInclude setting.
cylonid commentedon Apr 16, 2018
Sean McManus (@sean-mcmanus) Ok, now I see what you mean... In my case, the forced includes are not needed for compilation at all, so my compile_commands.json does not know about them. I only specified them inside c_cpp_properties.json because they are needed for proper auto-completion inside VSC. I was not aware that this use case could be unusual.
bobbrow commentedon Apr 16, 2018
Can you tell us what exactly isn't working for auto-completion? Are system includes/defines missing? If you can share an entry from the compiler_commands.json for a file where things are not working properly, we might be able to figure out if there is a bug elsewhere since you shouldn't need to use forcedInclude with compile_commands.json.
cylonid commentedon Apr 16, 2018
Actually this is a duplicate of my own issue #1699. My issue occurs because IntelliSense is limited to included headers, even with a compile_commands.json where the entry for the respective file includes the folder with the needed header.