VSCode C++终端进程终止,退出代码:1

8wtpewkr  于 4个月前  发布在  Vscode
关注(0)|答案(2)|浏览(148)

我想使用VSCode在C中进行基本的数据排序,并且需要包含一个新的库;在这样做的时候,我想我不小心在后台搞砸了一些严重的事情(可能是.json文件之一),因为每次我尝试通过MinGW用g构建最基本的程序时,都会收到消息“终端进程终止于退出代码:1.即使是一个基本的“Hello World”项目,我知道它可以工作,并且以前被制作成.exe,也不会再编译成可执行文件。helloworld.cpp

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

using namespace std;

int main()
{
    std::cout <<"Hello World!\n";
    
}

字符串
我试着重新启动窗口,重新安装VSCode,在不同的目录中启动一个新项目,使用默认的json文件以防我改变了一些我不应该做的事情......我习惯于通过gFortran用FORTRAN和通过Anaconda用Spyder用Python做类似的数据任务,但是我对C++和VSCode都没有经验,并且对做一些像运行程序这样简单的事情的复杂程度越来越感到沮丧。
任何关于如何解决这个问题的建议都是有帮助的;我已经检查了其他类似的问题,没有任何建议起作用。

Tasks.json

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

cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.17134.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64/cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

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": [
    {
        "name": "(Windows) Launch",
        "type": "cppvsdbg",
        "request": "launch",
        "program": "${workspaceFolder}/helloworld.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false
    }
]


}

mklgxw1f

mklgxw1f1#

对我来说,问题是在运行时编译器没有注意到的错误。所以你必须检查你的脚本是否正常,即使调试器没有发现错误。

wmomyfyw

wmomyfyw2#

我去了同样的问题,在情况下退出代码终止与-1作为花2小时,然后发现有错误的代码,当我点击错误按钮没有错误,因为我没有得到预期的输出后,看到程序这么多,我发现我的程序中的小错误增加了复杂性,所以我建议仔细检查代码文件的每一行,在我的情况下,问题是通过做代码纠正解决.

相关问题