VSCode 是否可以在 Windows 7 上很好地调试代码?

时间:2021-05-18 08:41:31

标签: vscode-settings vscode-debugger

我在我的 windows7 上安装了 VSCode 和 MinGW-W64 并且想要运行 c/c++ 代码。但是在运行 hello 程序后,我发现它无法进入调试模式。下面是我从教程中复制的代码:

hello.cpp:

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{

vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};

for (const string& word : msg)
{
    cout << word << " ";
}
cout << endl;

}

launch.jason:

{

"version": "0.2.0",
"configurations": [
  {
    "name": "C/C++: g++.exe build active file",
    "type": "cppdbg",
    "request": "launch",
    "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
    "stopAtEntry": false,
    "customLaunchSetupCommands": [
      { "text": "target-run", "description": "run target", "ignoreFailures": false }
    ],
    "launchCompleteCommand": "exec-run",
    "linux": {
      "MIMode": "gdb",
      "miDebuggerPath": "/usr/bin/gdb"
    },
    "osx": {
      "MIMode": "lldb"
    },
    "windows": {
      "MIMode": "gdb",
      "miDebuggerPath": "E:\\Program Files (x86)\\MingGW\\mingw64\\bin\\gdb.exe"
    }
  }
]

}

task.jason:

{

"version": "2.0.0",
"tasks": [
  {
    "type": "shell",
    "label": "C/C++: g++.exe build active file",
    "command": "g++",
    "args": ["-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
    "options": {
      "cwd": "${workspaceFolder}"
    },
    "problemMatcher": ["$gcc"],
    "group": {
      "kind": "build",
      "isDefault": true
    }
  }
]

}

我只在 vscode 中安装 c/c++ 扩展。安装时有什么我想念的吗?还是 VSCode 在 windows7 下能正常工作?

0 个答案:

没有答案