VSCODE配置tasks.json

发布时间 2023-07-24 19:59:57作者: DawnTraveler

1.新建配置任务tasks.json

image-20230724194948159

选择gcc.exe

image-20230724195027146

可以在其中按需修改

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++: gcc.exe 生成活动文件",
      "command": "C:\\MinGW\\bin\\gcc.exe",
      "args": [
        "-fdiagnostics-color=always",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}\\${fileBasenameNoExtension}.exe"
      ],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": ["$gcc"],
      "group": "build",
      "detail": "编译器: C:\\MinGW\\bin\\gcc.exe"
    }
  ]
}

2.使用

点击task

image-20230724195132872

选择活动文件

image-20230724195141889

成功!

image-20230724195211835