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
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:
A foo/src/main.c file that does #include "include/foo.h" (file = foo/include/foo.h)
foo/include/foo.h does #include "bake_util.h" (file = foo/include/bake_util.h)
foo/include/bake_util.h does #include <bar> (file = $HOME/bake/include/bar)
$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:
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.
The text was updated successfully, but these errors were encountered:
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).
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.
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.
Type: LanguageService
Describe the bug
To reproduce
I have a workspace with a single folder "foo" (not the workspace root), which contains a C project that looks like this:
foo/src/main.c
file that does#include "include/foo.h"
(file =foo/include/foo.h
)foo/include/foo.h
does#include "bake_util.h"
(file =foo/include/bake_util.h
)foo/include/bake_util.h
does#include <bar>
(file =$HOME/bake/include/bar
)$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 thefoo
project. Bothfoo
andbar
are located at the same level inside the workspace root. The workspace configuration file is stored at the same level asfoo
andbar
.The workspace configuration file (
.code-workspace
) looks like this: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"
fromfoo/include/foo.h
, Intellisense also discoversbake_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 followbar
's symbols used byfoo
to their definitions inbar/include/bar.h
. However, in thebar.h
file, many errors are reported because of a missing macro definition bybar/include/bake_util.h
. It seems like Intellisense does not know whichbake_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
#include < .. >
andinclude " .. "
, which it doesn't seem to do.includePath
array.Additional context
The console does not show any errors related to the include file in step 4.
The text was updated successfully, but these errors were encountered: