vscode可以编译通过c++项目,但头文件有红色波浪线的问题
1、打开 VSCode 的设置,可以通过快捷键 Ctrl + Shift + P 打开命令面板,然后搜索并选择 “C/C++: Edit Configurations (JSON)” 命令,这将在 .vscode 文件夹中创建或修改 c_cpp_properties.json 文件
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/opt/rh/devtoolset-7/root/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
2、在 c_cpp_properties.json 文件中,找到 “includePath” 属性,并添加你的头文件路径。确保在每个路径后面加上 /**,以便 VSCode 能够查找这些目录及其子目录中的头文件
我这里添加了muduo的头文件路径
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**" ,"/home/cxq/RPC/build/release-install-cpp11/include"
],
"defines": [],
"compilerPath": "/opt/rh/devtoolset-7/root/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}