Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS code: include file not found in browse. path.?

IN VS CODE i get the error "include file not found in browse. path." with an error squiggle under my header file #include <stdio.h> how can i make this library accessible to my code.

all i have is a folder and a main.c file

Very new to all this, the other answers seem to be out of my depth as im not sure what files they're accessing. Thank you in advance.

like image 561
Cell Avatar asked Aug 11 '17 17:08

Cell


3 Answers

Very similar problem to the one posed here, and thankfully a very similar solution.

Ctrl-Shift-P will open the "command bar", start trying C/Cpp: Edit Configurations until it's the top result then hit enter, this will create a c_cpp_properties.json file in the .vscode folder of your current project directory (making this configuration unique to this project, so you'll need to repeat this for other projects). This json file has sections for Mac, Linux and Win32, edit the section relevant to you or all if you know the paths for the other platforms. Each block has a name, includePath, defines, intelliSenseMode and browse property. The browse property has a child array called path (which is what we're looking for, include file not found in *browse.path*), add the paths to your include directories here, one string each, and remember to use forward slashes even if Windows gives you them as backward slashes.

While the offending error disappeared when adding the correct path to browse.path, I also added it to the includePath section because according to the hover tooltip includePath is used by the intellisense engine whereas browse.path is used by the tag parser. Can't hurt to have both set up correctly.

like image 59
Mark A. Ropper Avatar answered Oct 02 '22 21:10

Mark A. Ropper


Attaching example of .vscode\c_cpp_properties.json file with browse.path which solved my issues with Arduino dependencies

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTProtocol_MQTT\\src\\**",
                "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTUtility\\src\\**",
                "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTHub\\src\\**",
                "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\WiFiManager\\**",
                "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\ArduinoJson\\**",
                "C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**",
                "C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.2\\**",""
            ],
            "forcedInclude": [],
            "browse": {
                "path":[
                    "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTProtocol_MQTT\\src\\**",
                    "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTUtility\\src\\**",
                    "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTHub\\src\\**",
                    "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\WiFiManager\\**",
                    "C:\\Users\\localuser\\Documents\\Arduino\\libraries\\ArduinoJson\\**",
                    "C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**",
                    "C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.2\\**"]
            },
            "intelliSenseMode": "msvc-x64",
            "compilerPath": "C:\\WinAVR-20100110\\bin\\avr-gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}
like image 43
George Trifonov Avatar answered Oct 02 '22 20:10

George Trifonov


All you need to have is, to check if browse.path exists in the c_cpp_properties.json file. If not include this part. It should fix the issue.

   {
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64",
            "browse": {
                "path": ["${workspaceFolder}"],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
              }
        }
    ],
    "version": 4 }
like image 29
Deb Avatar answered Oct 02 '22 21:10

Deb