在下在使用VSCode的时候遇到了以下问题#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/home/pi/works/mqtt_demo/mqtt_client.c).C/C++(1696),虽然说我实际开发编译是通过编写Makefile实现的,对我实际开发并不造成影响,但是IDE老是那么红着,显示 ERROR ,实属不雅:
那么问题来了,怎么给VSCode添加头文件的搜索路径呢?
1)在vscode中按Ctrl+Shift+P 输入configuration,选择C/C++:Edit Configuration(JSON);
2)编辑打开的c_cpp_properties.json文件,在configurations里的includePath中添加你需要引入的头文件的路径,保存即可。
修改前:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-arm"
}
],
"version": 4
}
修改后:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include/cjson/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-arm"
}
],
"version": 4
}
修改完成后,不显示 ERROR 了。