NCS 1.8 VS Code #Include Errors

Today I opened VS Code to find all my Zephyr/NRF #includes have the red squiggly lines with an error such as "cannot open source file zephyr/types.h". Right click -> Go to Definition also does not work for these includes. The same thing happens in all my projects. Build and Pristine Build work fine to build the program but do not resolve this problem. I suspect there was a VS Code or extension related update that broke the Intellisense? Any help is appreciated.

Potentially related, sometimes projects randomly will not build with the error seen below. Reopening VS Code fixes this.

  • Not sure if this is the correct way, but I've fixed this by doing the following:

    -right clicking on the error and selecting the "add include path" option (this creates a c_cpp_properties.json file inside a .vscode folder)

    -open the json file, under "includePath" there should be a path to your SDK location "ncs/v1.8.0/zephyr/include"

    -still in this json file, change "configurationProvider" from the default value to "nrf-connect"

    Interesting to note, the .vscode folder and c_cpp_properties.json did not exist in my projects before which never had this problem, so I assume there was an update that now requires you to have this file setup.

Related