#include errors detected in vscode

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


Close and re-open Visual Studio Code.


If you are working with cmake-tools and the error messages says something is wrong with the configurationProvider, then you have 2 options:

  1. Use ms-vscode.cpptools instead of ms-vscode.cmake-tools
  2. Define the headers in CMakeLists.txt

Option 1: Use ms-vscode.cpptools instead of ms-vscode.cmake-tools.

  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

Option 2: Define the headers in CMakeLists.txt

When configurationProvider is set to ms-vscode.cmake-tools in c_cpp_properties.json, VS Code uses the include information defined in the CMakeLists.txt instead of reading the includePath configs in VS Code.

So you need to setup the include path correctly:

  1. using the include_directories command (rather than the target_include_directories command) to define the headers
  2. Configure the project to reflect the change happened in the previous step.