【问题标题】:the files with their name having space are not getting compiled名称有空格的文件没有被编译
【发布时间】:2020-05-27 10:34:42
【问题描述】:

用 vscode 编译我的 c++ 程序。名称中有空格的文件没有被编译

    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "shell: g++.exe build active file",
            "command":"C:\\Program Files (x86)\\CodeBlocks\\MinGW\\bin\\g++.exe",
            "args": ["-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "-std=c++11"],
            "options": {
                "cwd":"C:\\Program Files (x86)\\CodeBlocks\\MinGW\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}```



【问题讨论】:

  • 最简单的解决方案是不要让文件名包含空格。
  • 使用 "\"${file}\"" 并引用 .exe,就像 Sam 所说的更好:永远不要在文件名中使用空格

标签: c++ visual-studio-code compiler-errors compilation


【解决方案1】:

就是这样。查看 VSCode 用于编译和运行的命令和 c++ 文件:

cd "c:\Users\Deep Raval\Desktop\" ; if ($?) { g++ -std=c++14 garbage 2.cpp -o garbage 2 } ; if ($?) { .\garbage 2 }

更具体的间隔文件会造成天气混淆,它是命令还是实际文件名。

要解决问题,您可以使用_ 而不是space

或者您可以根据您的操作系统设计自定义命令。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-28
    • 1970-01-01
    相关资源
    最近更新 更多