【发布时间】:2018-12-25 10:20:07
【问题描述】:
我的来源file.cpp:
#include <iostream>
using namespace std;
int main()
{
int x = 1;
int y = 2;
cout << x + y << endl;
return 0;
}
我使用g++ -g file.cpp编译它,然后我的launch.json文件是这样的:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
我的目录结构是:
- workspaceFolder
- .vscode
- launch.json
- a.out
- file.cpp
当我单击“调试”选项卡中的绿色“开始调试”箭头时,我在“调试控制台”中收到此错误:
Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object
我做错了什么?我查看了每个教程,调试 C++ 似乎对所有教程都有效,但我的情况除外。我还安装了 C/C++ (Microsoft) 扩展,并且正在运行 Ubuntu 64 位。
【问题讨论】:
标签: c++ visual-studio-code vscode-debugger