The C/C++ Extension is used to provide C and C++ syntax highlight, code navigation and Go to declaration/definition within C and C++ files.
The default configuration file is located in {PROJECT_DIR}/.vscode/c_cpp_properties.json
and can be generated by using ESP-IDF: Create project from extension template command or using the ESP-IDF: Add vscode configuration folder command.
To enable Code Navigation, auto-complete and other language support features on ESP-IDF source files on Visual Studio Code. Please take a look at C/C++ Configurations for more detail about c_cpp_properties.json configuration fields.
With this configuration file, 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.
For this configuration to work, you need to set you C/C++ Extension IntelliSense engine to Tag Parser by using C_Cpp.intelliSenseEngine": "Tag Parser"
in your settings.json.
An example configuration that should work with most projects is shown below.
{
"configurations": [
{
"name": "ESP-IDF",
"cStandard": "c11",
"cppStandard": "c++17",
"includePath": [
"${config:idf.espIdfPath}/components/**",
"${config:idf.espIdfPathWin}/components/**",
"${workspaceFolder}/**"
],
"browse": {
"path": [
"${config:idf.espIdfPath}/components",
"${config:idf.espIdfPathWin}/components",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": false
},
"compilerPath": "/path/to/toolchain-gcc"
}
],
"version": 4
}
NOTE: When you create a project using the extension commands such as
Show Examples Projects
,New Project
,Create project from extension template
or you add the configuration files to an existing project using theAdd vscode configuration folder
, this file is created with the compilerPath of the configured toolchain for your currentidf.adapterTargetName
.
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.
{
"configurations": [
{
"name": "ESP-IDF",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}