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

Intellisense does not seem to correctly resolve include files included with "" #3138

Closed
SanderMertens opened this issue Feb 6, 2019 · 4 comments
Labels
bug Language Service more info needed The issue report is not actionable in its current state

Comments

@SanderMertens
Copy link

SanderMertens commented Feb 6, 2019

Type: LanguageService

Describe the bug

  • OS and Version: MacOS 10.14.1
  • VS Code Version: 1.31.0
  • C/C++ Extension Version: 0.21.0
  • Other extensions you installed (and if the issue persists after disabling them):
    • GitLens

To reproduce
I have a workspace with a single folder "foo" (not the workspace root), which contains a C project that looks like this:

  1. A foo/src/main.c file that does #include "include/foo.h" (file = foo/include/foo.h)
  2. foo/include/foo.h does #include "bake_util.h" (file = foo/include/bake_util.h)
  3. foo/include/bake_util.h does #include <bar> (file = $HOME/bake/include/bar)
  4. $HOME/bake/include/bar does #include "bar.dir/bar.h" (file = $HOME/bake/include/bar.dir/bar.h)

There is also a bar folder in the workspace root, but it is not added to the workspace configuration. The bar project follows the same structure as the foo project. Both foo and bar are located at the same level inside the workspace root. The workspace configuration file is stored at the same level as foo and bar.

The workspace configuration file (.code-workspace) looks like this:

{
	"folders": [
		{
			"path": "foo"
		}
	],
	"settings": {
		"files.associations": {
			"chrono": "c",
			"limits": "c",
			"ratio": "c",
			"algorithm": "c",
			"iterator": "cpp",
			"string": "cpp",
			"string_view": "cpp",
			"vector": "cpp",
			"__locale": "c",
		},
		"C_Cpp.default.includePath": [
			"${env:HOME}/bake/include",
			"${workspaceFolder}"
		]
	}
}

There are no folder-specific settings (no foo/.vscode/c_cpp_properties.json).

Up to step 3, Intellisense is able to find all the include files. However, it is unable to navigate to the last file, $HOME/bake/include/bar.dir/bar.h. Note that in between each step, I wait until Intellisense has finished (I wait until the red flame icon disappears from the bottom right corner). Additionally, I am observing other unexpected behavior:

  • When navigating #include "bake_util.h" from foo/include/foo.h, Intellisense also discovers bake_util.h files from other folders in the workspace root, even though these folders are not added to the workspace configuration, nor the include path.

  • Because Intellisense discovers symbols from bar, I am able to follow bar's symbols used by foo to their definitions in bar/include/bar.h. However, in the bar.h file, many errors are reported because of a missing macro definition by bar/include/bake_util.h. It seems like Intellisense does not know which bake_util.h to use, even though the include statement disambiguates this (it does #include "bake_util.h" instead of #include <bake_util.h> which should search local directories first).

Expected behavior

  • I would expect Intellisense to correctly interpret the difference between #include < .. > and include " .. ", which it doesn't seem to do.
  • I would expect Intellisense to only consider files in the workspace "folders" section, and to only lookup include files from the paths in the includePath array.
  • I would expect Intellisense to be able to resolve the include file in step 4.

Additional context
The console does not show any errors related to the include file in step 4.

@sean-mcmanus
Copy link
Collaborator

The "navigate" or Go to Def on #include feature currently doesn't use IntelliSense's include path so it can show too many files -- see #2564 for the issue tracking that.

I tried to follow all your setup steps, but I'm not able to reproduce any other bug. Is this the correct setup in the screenshot? Can you send us or attach an isolated repro project? IntelliSense is normally able to handle #include "" correctly. The include in step 4 is resolved. I'm able to get symbols from all the correct files with no error squiggles (2nd screenshot).

image

image

@sean-mcmanus sean-mcmanus removed their assignment Feb 9, 2019
@sean-mcmanus sean-mcmanus added more info needed The issue report is not actionable in its current state and removed investigate This issue needs to be investigated/confirmed labels Feb 9, 2019
@SanderMertens
Copy link
Author

The behavior changed in the latest version, but it still cannot find the headers. I will need some time to investigate and come up with an updated issue description.

@michelleangela
Copy link
Contributor

Closing this issue due to long inactivity. If you update to the latest version of the C/C++ extension and your issue still persists, please re-open the issue and reply with additional information that can help us investigate the issue.

@sean-mcmanus
Copy link
Collaborator

@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Language Service more info needed The issue report is not actionable in its current state
Projects
None yet
Development

No branches or pull requests

3 participants