c++ - ${workspaceFolder}\\*.cpp 显然未被识别为 vscode tasks.json 中的有效路径

标签 c++ gcc visual-studio-code

在我的工作区文件夹中按 ctrl+shift+b 时,我得到 The terminal process terminated with exit code 1。这似乎意味着路径不正确。然而,我在这里遵循 Microsoft 的说明:

https://code.visualstudio.com/docs/cpp/config-mingw#_modifying-tasksjson

我还检查了 stackoverflow,这绝对有效。当我将 *.cpp 替换为 main.cpp 时,它编译没有问题。我现在只有一个文件,但将来肯定会有更多。

我使用的是 vscode 1.44.2,g++ 9.3.0。

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

My workspace folder

最佳答案

您是否在目录中任何文件夹的名称之间放置了空格?放置一个空格会使目录无效(即“我的项目”将不会被识别,但“我的项目”会)。似乎这可能是问题所在。我遇到了同样的问题,这解决了我的问题。

关于c++ - ${workspaceFolder}\\*.cpp 显然未被识别为 vscode tasks.json 中的有效路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61328894/

相关文章:

c++运行并发for循环,甚至可能吗?

c++ - 错误 C1083 : Cannot open include file: 'FL/Fl.h' : No such file or directory

c++ - mexPrintf 消息未显示在 matlab 命令窗口中

c - 在 c 中未定义对 'function' 的引用,而该函数已定义

c - “asm”操作数具有不可能的约束

android - React Native 应用程序开始出现白屏

visual-studio-code - 关闭visual studio代码内联父/子文件夹显示

c++ - 以下短 argc 和 argv 代码的输出

c - 如何避免 gcc 编译器使用 -l 选项?

transactions - 写一个TypeORM@Transaction方法,使用这个方法IDE报错 "Invalid number of arguments, expect 2"