1. 代码补全
有时候 clangd
压根没什么用
还是 c++ 插件比较靠谱
C++插件需要分析compile_commands.json
在 .vscode/c_cpp_properties.json
配置 json的路径
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${default}",
"${workspaceFolder}/build/_deps/googletest-src/googletest/include/"
], // 有时候找不到就直接在这里加,然后重启
"defines": [],
"compilerPath": "/usr/bin/gcc",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
compile_commands.json
的生成需要 set(CMAKE_EXPORT_COPILE_COMMANDS ON) 用cmake生成。
2.代码生成
有时候需要用脚本生成
编辑 task.json
type=shell
command:...
还有 options : {env: {} }
3.代码调试
编辑 launch.json
一般就是把 debug的程序的绝对路径,参数 gdb等信息,可以使用 cuda-gdb