我正在尝试学习c ++,但是要使其在Visual Studio代码中运行有些麻烦。我启用了c ++和代码运行器扩展。已安装mingw。 (该文件称为hello.cpp)
settings.json
{
"workbench.iconTheme": "vscode-icons",
"code-runner.runInTerminal": true,
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-o",
"hello",
"hello.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}