#include errors detected in vscode

336,202

Solution 1

The answer is here: How to use C/Cpp extension and add includepath to configurations.

Click the light bulb and then edit the JSON file which is opened. Choose the right block corresponding to your platform (there are Mac, Linux, Win32 – ms-vscode.cpptools version: 3). Update paths in includePath (matters if you compile with VS Code) or browse.paths (matters if you navigate with VS Code) or both.

Thanks to @Francesco Borzì, I will append his answer here:

You have to Left 🖰 click on the bulb next to the squiggled code line.

If a #include file or one of its dependencies cannot be found, you can also click on the red squiggles under the include statements to view suggestions for how to update your configuration.

enter image description here

Solution 2

Close and re-open Visual Studio Code.

Solution 3

If you are working with cmake-tools and the error messages says something is wrong with the configurationProvider, then following actions solved the issue for me:

  1. Open c_cpp_properties.json. (windows key on windows or cmd key on mac + shift + p, enter "c/c++ edit configurations" and chose 'json'.
  2. Enter ms-vscode.cpptools as value for configurationProvider instead of ms-vscode.cmake-tools or whatever you have.

How it should look like after the replacement of configurationProvider:

enter image description here

One other important configuration is the include path. The assumption is that you have this configuration right. May be like following

enter image description here

Solution 4

  • Left mouse click on the bulb of error line
  • Click Edit Include path
  • Then this window popup

enter image description here

  • Just set Compiler path

Solution 5

I ended up here after struggling for a while, but actually what I was missing was just:

If a #include file or one of its dependencies cannot be found, you can also click on the red squiggles under the include statements to view suggestions for how to update your configuration.

enter image description here

source: https://code.visualstudio.com/docs/languages/cpp#_intellisense

Share:
336,202
banan3'14
Author by

banan3'14

Updated on January 06, 2022

Comments

  • banan3'14
    banan3'14 12 months

    I am using Visual Studio Code in my C++ project. I installed Microsoft C/C++ Extension for VS Code. I got the following error:

    #include errors detected. Please update your includePath. IntelliSense features for this translation unit (/path/to/project/file.cpp) will be provided by the Tag Parser.

  • Hatted Rooster
    Hatted Rooster almost 4 years
    Please add that your answer contains a part of @Francesco's answer, as in, he was first but you're just adding it to yours for visibility. Otherwise it looks like Francesco is blatantly copying your answer.
  • banan3'14
    banan3'14 almost 4 years
    Right, forgot to acknowledge him
  • Scott McPeak
    Scott McPeak over 3 years
    Regarding includePath and browse.path: your explanation is not quite right. Both are used while browsing, neither is used during compilation. See the VSCode FAQ and another answer of mine.
  • Aaron Franke
    Aaron Franke almost 3 years
    What do I do if the include error is a native library? VS Code is complaining about #include <mono/metadata/assembly.h>
  • Aaron Franke
    Aaron Franke almost 3 years
    What if there are no suggestions?
  • Ethan Groat over 2 years
    'Add to "includePath"' is not an option on my editor, which does have the C/C++ extension. Could I get some insight as to why?
  • banan3'14
    banan3'14 about 2 years
    @EthanGroat, perhaps you have disabled error squiggles? Could you check options C_Cpp.errorSquiggles and C_Cpp.default.enableConfigurationSquiggles in settings?
  • Sihat Afnan
    Sihat Afnan almost 2 years
    If you don't have g++ installed, install it with sudo apt-get install g++
  • Mrityunjai over 1 year
    simple and to the point! Is there any shortcut like invalidate cache and rebuilt indexes?
  • J-D3V
    J-D3V over 1 year
    If there is a lightbulb, there are suggestions
  • Aqua about 1 year
    This fixed my issue! Thank you!
  • akash about 1 year
    After above steps, please restart the vs code.
  • Aaron Franke
    Aaron Franke about 1 year
    I have this set to /usr/bin/g++, IntelliSense mode set to linux-gcc-x64, and the include path set to include ${workspaceFolder}/** and I still get include path errors. I do have GCC and G++ installed. I have the same problem with Clang.
  • Pluviophile
    Pluviophile about 1 year
    This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
  • BugHunterUK
    BugHunterUK 11 months
    The problem is, I am not getting the option to add to the include path.
  • banan3'14
    banan3'14 11 months
    @BugHunterUK is it possible to add/change includePath manually? See this answer for further guidance stackoverflow.com/a/68139743/7769052.
  • Hassan Risvy
    Hassan Risvy 7 months
    Simple & Starightforward! Solved my problem! Thanks!
  • Alessandro Giusa 7 months
    Before making this change, check if a restart of vscode helps.
  • HAO LEE 6 months
    This is the correct solution!!!!!