microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.21k stars 29.29k forks source link

IntelliSense Errors when Using Multiple .cpp Files #206435

Closed Sochsenfeld closed 8 months ago

Sochsenfeld commented 8 months ago

Type: Bug

My Project contains multiple .cpp files that are all included in the main.cpp. The main.cpp also contains all the neccessary libraries for compiling. For example the Definitions.cpp contains

using std::cout;

and the cout is underlined with errors as the standard library is not detected. Same goes with variables that are defined in one file and used in another. Only the main.cpp knows about them all. The intellisense always worked in a way that it knew that the files are included in main and crosschecked all the files. It suddenly stopped working a while ago, then I did a clean reinstall of visual studio code and it worked again. Now yesterday it suddenly stopped working again, seemingly out of thin air. The code compiles perfectly fine and runs as intended but just the intellisense interface is acting up and making working with code very hard. I have looked if anyone has the same problem but i cant even find anyone with a similar problem.

VS Code version: Code 1.86.2 (903b1e9d8990623e3d7da1df3d33db3e42d80eda, 2024-02-13T19:40:56.878Z) OS version: Windows_NT x64 10.0.19045 Modes: Remote OS version: Linux x64 5.4.72-microsoft-standard-WSL2 Remote OS version: Linux x64 4.18.0-477.27.1.el8_8.x86_64

Extensions (30) Extension|Author (truncated)|Version ---|---|--- better-cpp-syntax|jef|1.17.2 gnuplot|mam|1.0.5 remote-containers|ms-|0.338.1 remote-ssh|ms-|0.108.0 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.86.0 vscode-remote-extensionpack|ms-|0.25.0 remote-explorer|ms-|0.4.1 remote-server|ms-|1.5.0 material-icon-theme|PKi|4.34.0 ayu|tea|1.0.5 npm-intellisense|chr|1.4.5 doxdocgen|csc|1.4.0 gitlens|eam|14.8.2 vscode-pull-request-github|Git|0.80.1 better-cpp-syntax|jef|1.17.2 bash-ide-vscode|mad|1.39.0 gnuplot|mam|1.0.5 debugpy|ms-|2024.0.0 isort|ms-|2023.10.1 python|ms-|2024.0.1 vscode-pylance|ms-|2024.2.2 cmake-tools|ms-|1.17.17 cpptools|ms-|1.19.4 cpptools-extension-pack|ms-|1.3.0 makefile-tools|ms-|0.8.22 material-icon-theme|PKi|4.34.0 synthwave-vscode|Rob|0.1.15 ayu|tea|1.0.5 cmake|twx|0.0.17 (8 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:30968132 pythontbext0:30879054 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 pydisww2:30959801 d34g3935:30971562 edj9j583:30969295 fegfb526:30973843 bg6jg535:30958357 ccp1r6:30958156 dsvsc020:30973508 ```

bugreport1 bugreport2 bugreport3

the-coder-o commented 8 months ago

IntelliSense Cache: Clear the IntelliSense cache. This can usually be done within the IDE settings. IntelliSense might be getting confused due to outdated or corrupted cache entries.

Rebuild the Project: Sometimes simply rebuilding the entire project can resolve such issues. If there are any temporary glitches, a rebuild can often fix them.

Check Include Paths: Make sure that the include paths for the standard library are correctly set up in your project's settings. If the IDE does not know where to look for the standard headers, it will not recognize standard library objects like std::cout.

Update the IDE: Check if there are any updates available for your IDE and install them. Sometimes bugs that cause these types of issues are fixed in updates.

Recreate the Project: As a last resort, try recreating the project from scratch and add your source files again. This can often resolve configuration issues.

Compiler Issues: Ensure that the compiler is correctly installed and configured. If you are using a remote compiler or a different version of the compiler on a remote system, there may be discrepancies causing this issue.

Code Analysis Tools: Use code analysis tools or other linters to check if there are any other unseen issues in your code that might be causing IntelliSense to malfunction.

Consult IDE/Compiler Documentation: Sometimes these issues can be specific to the IDE or compiler you're using. Consult the documentation for any known issues or troubleshooting steps.

Seek Support from the IDE Community: If the issue persists, consider seeking help from the community or forums related to the IDE you are using.

Check for Conflicting Code: Look for any macro definitions or conflicting code that might be causing cout to be undefined.

Sochsenfeld commented 8 months ago

How do you effectively clear the intellisense cache? I used the option C/C++: Reset IntelliSense Database. After that the problem persists. I also tried "Developer: Reload Window with Extensions Disabled". Nothing works. The include paths are also fine, also the code compiles without errors or warnings.

the-coder-o commented 8 months ago

Manually delete the cache files from the disk. Check if the problem is related to a specific project or all projects. Disable all extensions and re-enable them one by one to identify if an extension is causing the problem. Check the output or problems tab for any underlying issues that might not be obvious. Update the software (e.g., Visual Studio Code, or the C/C++ extension) to the latest version.

Sochsenfeld commented 8 months ago

Can you help me locating these files locally? The problem occurs with every project, even projects that are very old and werent opened until recently and then the problem occurred for the first time. Ill be checking the extensions right now. The output tab shows nothing and the problem tab just shows the errors that intellisense falsely catches. Visual studio code and the C/C++ extension is on the latest version.

the-coder-o commented 8 months ago

Screenshot 2024-02-28 191823 Screenshot 2024-02-28 191830 Screenshot 2024-02-28 191838 Screenshot 2024-02-28 191844

Sochsenfeld commented 8 months ago
  1. checked 2. checked 3. checked and tried 4. tested singular extensions and no single extension seemed to be the problem. I cannot choose c/c++ in the dropdown menu for the output menu 5. tried and did not solve the problem 6. every file that is not directly inclusing libraries has the problem, so no specific file. Im attaching also two pictures that maybe can give more insight? bugreport4 bugreport5
the-coder-o commented 8 months ago

whta is your native language?

the-coder-o commented 8 months ago

please tell me, it is very important fo me

Sochsenfeld commented 8 months ago

Its german, why?

the-coder-o commented 8 months ago

1 minut bro

the-coder-o commented 8 months ago

I am going to fix the error

the-coder-o commented 8 months ago

image

please, try this

mjbvz commented 8 months ago

/extC++

vscodenpa commented 8 months ago

It looks like this is caused by the C++ extension. Please file the issue to the C++ extension repository. Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our issue reporting guidelines for more information.

Happy Coding!