c - C 调试功能中的 Visual Studio Code Hello World 不起作用 Programm NullReferenceException :

标签 c json ubuntu debugging visual-studio-code

我尝试在 Ubuntu 18.04.1 上使用 Visual Studio Code 1.30.1 中的调试功能作为调试扩展,我使用 ms-vscode.cpptools 中的 C/C++ 0.20.1。 我用 gcc -Wall -g main.c -o main 编译了 main.c

这是main.c的代码

#include <stdio.h> 

int main ()
{
printf("Hello World\n");
}

launch.json 配置

 {
 // Use IntelliSense to learn about possible attributes.
 // Hover to view descriptions of existing attributes.
 // For more information, visit: https://go.microsoft.com/fwlink   /?linkid=830387
"version": "0.2.0",
"configurations": [

    {
        // for Linux
        "name": "gdb C",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceRoot}/a.out",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceRoot}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        //"preLaunchTask": "build cunit",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          }
        ]
      }
    ]
  }

当我启动调试器时,我得到

Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object

Visual Studio 代码版本:

版本:1.30.1 提交:dea8705087adb1b5e5ae1d9123278e178656186a 日期:2018-12-18T18:07:32.870Z 电子:2.0.12 Chrome :61.0.3163.100 Node.js:8.9.3 V8:6.1.534.41 操作系统:Linux x64 4.15.0-43-generic

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 C",
        "type": "shell",
        "group": {
            "kind": "build",
            "isDefault": true
        },
        //"command":"gcc -g main.c -std=c11 -Werror -Wall -lm"
        "command":"gcc -Wall -g main.c"
    }
]
}

最佳答案

我的版本似乎是软件中的一个错误。您可以设置 "externalConsole": false 并且调试功能正常工作(这是一个解决方法)。

关于c - C 调试功能中的 Visual Studio Code Hello World 不起作用 Programm NullReferenceException :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54055042/

相关文章:

qt - 如何在 64 位 Ubuntu 上构建 32 位 Qt5 应用程序

ubuntu - 在 Ubuntu 上安装 Sqlplus

c - 是否可以使用 #if 到 mcro 函数中检查宏参数

python - Cython 代码 : Python. h 没有那个文件或目录

java - Android 与 ReSTLet/JSON/Jackson 的兼容性

json - jq 删除重复的对象之一

ruby - 这是不是root登录的问题?

c - 我想创建一个程序来检查输入在 C 中的语法是否有效

线条的颜色没有变化?

javascript - 如何过滤 Ajax 响应并附加到最​​后一个响应之上?