刚下vscode的没几天,配置个c++让我爆炸了,首先是编译问题,试了很多方法,最后还是推荐一种最简单的方法,
直接下载一个插件:C/C++ Compile Run,非常好用,直接F6就可以编译运行了,不需要配置launch.json和tasks.json,当然要配置也是没有问题的,
tasks.json的配置
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"${workspaceRoot}/${fileBasenameNoExtension}.o"
]
}
]
}
launch.json的配置:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/${fileBasenameNoExtension}.o",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"preLaunchTask": "build",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
基本适用的直接该就行了.