VSCODE配置文件cc++

2023-07-08 14:19:55 浏览数 (1)

liz例子

代码语言:javascript复制
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void) {
    #ifdef LOCAL
        freopen("in.in","r",stdin);
         freopen("out.out","w",stdout);
    #endif
    int a,b;
    cin>>a>>b;
    cout<<a b<<endl;
    return 0;
}

配置文件如下

launch.json

代码语言:javascript复制
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\MinGW\bin\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C  : g  .exe 生成活动文件"
        }
    ]
}

tasks.json

代码语言:javascript复制
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C  : g  .exe 生成活动文件",
            "command": "C:\MinGW\bin\g  .exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${workspaceFolder}/*.cpp",
                "-o",
                "${fileDirname}\${fileBasenameNoExtension}.exe",
                "-DLOCAL"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

in

1  2

out

3

在系统环境变量中设置路径

path添加

C:MinGWbin

之后在cmd中测试

gcc -v

0 人点赞