【问题标题】:How to set up VSCode's problem matcher with Linux-style gcc errors如何使用 Linux 风格的 gcc 错误设置 VSCode 的问题匹配器
【发布时间】:2020-10-01 19:00:34
【问题描述】:

我在安装了 MSYS2 + mingw-w64-x86_64-gcc + base-devel 的 Windows 7 上使用 VSCode。

我的项目有tasks.json,运行make 命令来构建:

{
    "tasks": [
        {
            "type": "shell",
            "label": "build",
            "command": "make",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "version": "2.0.0"
}

问题是GCC通过以下方式生成错误信息:

src/src_file.cpp:773:59: error: comparison of integer expressions of different signedness

$workspaceFolder变量中存储的项目路径为D:\myproject

文件的真实路径是D:\myproject\tools\src\src_file.cpp。在这种情况下,我不知道如何设置问题匹配器。我想Linux风格的斜杠会影响问题,但我不确定。我试图为匹配器设置regexp,但是我无法让它工作。

更新:

实际上斜线和反斜线不会影响结果。

【问题讨论】:

    标签: visual-studio-code mingw-w64


    【解决方案1】:

    使用这个问题匹配器,使用 $gcc 作为基础并定义文件位置

      "problemMatcher": {
        "base": "$gcc",
        "fileLocation": ["relative", "${workspaceFolder}/tools"]
      }
    

    编辑

    删除了src,因为它已经是错误消息的一部分。 (没发现)

    【讨论】:

      猜你喜欢
      • 2019-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-14
      • 2015-12-15
      • 2019-06-29
      相关资源
      最近更新 更多