在c_cpp_properties.json中添加 “compileCommands”:"${workspaceFolder}/build/compile_commands.json" 就可以了。
代码如下
c_cpp_properties.json:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"//在这里加入这行代码
}
],
"version": 4
}
然后就可以了。
参考:https://blog.youkuaiyun.com/weixin_35695879/article/details/85254422