Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force includes do not work if compile_commands is used #1842

Closed
cylonid opened this issue Apr 16, 2018 · 6 comments
Closed

Force includes do not work if compile_commands is used #1842

cylonid opened this issue Apr 16, 2018 · 6 comments
Labels
by design more info needed The issue report is not actionable in its current state

Comments

@cylonid
Copy link

cylonid commented Apr 16, 2018

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

@sean-mcmanus
Copy link
Collaborator

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 added more info needed The issue report is not actionable in its current state by design labels Apr 16, 2018
@cylonid
Copy link
Author

cylonid commented Apr 16, 2018

@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
Copy link
Collaborator

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
Copy link
Author

cylonid commented Apr 16, 2018

@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
Copy link
Member

bobbrow commented 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
Copy link
Author

cylonid commented 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.

@cylonid cylonid closed this as completed Apr 16, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
by design more info needed The issue report is not actionable in its current state
Projects
None yet
Development

No branches or pull requests

3 participants