【问题标题】:Build C++ in Powershell not CMD with Sublime Text 3使用 Sublime Text 3 在 Powershell 中构建 C++ 而不是 CMD
【发布时间】:2019-02-20 19:48:56
【问题描述】:

我想知道是否有办法在 Sublime Text 3 中运行构建,以便它在 Powershell 而不是 CMD 中输出。

{
    "cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
    "shell": true,

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
            "shell": true
        }
    ]
}

这是我在网上找到的代码,它将使用 MinGW 作为编译器,并允许您按 Ctrl + B 在 ST3 中构建 C++ 程序。执行此操作时,输出将转到 CMD 提示符。有没有办法让输出转到 Powershell?

【问题讨论】:

  • cmd/k 更改为 PowerShell 等效项(powershell-NoExit -Command 可能会起作用)。

标签: c++ powershell sublimetext3


【解决方案1】:

这肯定会奏效。

    {
    "cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
    "shell": true,

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["start", "powershell", "-NoExit", "${file_path}//${file_base_name}.exe"],
            "shell": true
        }
    ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    相关资源
    最近更新 更多