文章目录
头文件只能感应设置
通过编辑 .vscode/c_cpp_properties.json文件
(有波浪线,说明没有感应到,点击小灯泡,–> Edit includePath setting)
或者使用快捷键
Ctrl+P > edit c/c++ configuration
就会出现一个 c_cpp_properties.json文件
{
"configurations": [
{
"name": "Linux",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"${workspaceFolder}",
"${workspaceFolder}/lib/gstreamer"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
在includePath下,可以添加工程内的和系统内的依赖
手动安装 C/C++ Extension
C/C++ Extension: Downloading 2/4: ClangFormat (Linux / x86_64)
- 到 https://github.com/Microsoft/vscode-cpptools/releases 下载系统相对应的 cpptools.vsix
- 在VScode中 F1 使用 “Install from VSIX” command “Install from VSIX” command 手动安装插件
error Downloading package ‘C/C++ language components (Linux / x86_64)’
原因: 虽然电脑安装了C++的插件,但是需要联网下载依赖,但是不知道为什么最近怎么安装不上,所以只能手动安装。
解决办法:根据相应的插件版本,下载相应的依赖包,比如
0.21.0 版本的Linux包 https://github.com/Microsoft/vscode-cpptools/releases/download/0.21.0/cpptools-linux.vsix
然后 vscode中 view–>command Palettle–>install from VSIX 来安装这个vsis文件
参见 https://github.com/Microsoft/vscode-cpptools/releases