Skip to content

Commit

Permalink
Intellisense engine to search for headers automatically (VSC-165) (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
boarchuz authored and pwmb committed Jan 19, 2020
1 parent d51208b commit 3cc11ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions docs/C_CPP_CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The [C/C++ Extension](https://marketplace.visualstudio.com/items?itemName=ms-vsc

The file is located in {PROJECT_DIR}/.vscode/c_cpp_properties.json and can be generated by using **Create ESP-IDF Project** command.

## Default configuration without compile_commands.json
## Default configuration

This configuration doesn't require the compile_commands.json file generated by build process but requires to use the Tag Parser IntelliSense engine of the C/C++ extension which will explore directories specified in `configurations[i].browse.path` array. An example configuration that should work with most projects is shown below.
With this configuration, the Intellisense engine of the C/C++ extension will include all header files found by performing a recursive search of the `${config:idf.espIdfPath}/components` folder. Both **Default** and **Tag Parser** engines are supported. An example configuration that should work with most projects is shown below.

```
{
Expand All @@ -17,7 +17,7 @@ This configuration doesn't require the compile_commands.json file generated by b
"name": "Linux",
"cStandard": "c11",
"cppStandard": "c++17",
"includePath": ["${config:idf.espIdfPath}/components"],
"includePath": ["${config:idf.espIdfPath}/components/**"],
"browse": {
"path": [
"${config:idf.espIdfPath}/components"
Expand All @@ -30,11 +30,9 @@ This configuration doesn't require the compile_commands.json file generated by b
}
```

You need to have `idf.espIdfPath` and set `C_Cpp.intelliSenseEngine` to **Tag Parser** in your Visual Studio Code Settings (Directly in `settings.json` or using the **Preferences:: Open Settings (UI)** command) to allow headers to be resolved by browsing the `${config:idf.espIdfPath}/components` folder.

## Configuration with compile_commands.json

For this configuration you need to build your project beforehand to generate a `${workspaceFolder}/build/compile_commands.json`, where ${workspaceFolder} is your project directory, to able to resolve your C/C++ headers.
For this configuration, you must build your project beforehand in order to generate `${workspaceFolder}/build/compile_commands.json` (where ${workspaceFolder} is your project directory). This file will then be used to resolve your C/C++ headers.

```
{
Expand All @@ -43,9 +41,9 @@ For this configuration you need to build your project beforehand to generate a `
"name": "Linux",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
```
```
4 changes: 2 additions & 2 deletions templates/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Linux",
"cStandard": "c11",
"cppStandard": "c++17",
"includePath": ["${config:idf.espIdfPath}/components"],
"includePath": ["${config:idf.espIdfPath}/components/**"],
"browse": {
"path": [
"${config:idf.espIdfPath}/components"
Expand All @@ -14,4 +14,4 @@
}
],
"version": 4
}
}

0 comments on commit 3cc11ca

Please sign in to comment.