【问题标题】:Sublime text 3 Build System in C++ which takes input from TerminalSublime text 3 Build System in C++ 从终端获取输入
【发布时间】:2021-04-15 14:44:38
【问题描述】:

我正在寻找一个 sublime text 3 构建系统,它可以在 C++14 中运行我的程序,使用终端从用户那里获取输入,并在终端中显示我的输出。在网上搜索后,我在网上找到了这样一个构建系统。构建系统如下:

{
/* Custom Build file for C++14, supports input from user.
* Default terminal emulator is gnome-terminal. You can change it to xterm or
* terminator by changing "gnome-terminal -x" in "cmd" in "variants" field to
* "xterm -e" or "terminator -x".
*/
"cmd": ["g++", "-std=c++14", "$file", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ -std=c++14 '${file}' -o '${file_path}/${file_base_name}' && gnome-terminal -x bash -c '\"${file_path}/${file_base_name}\" ; read'"]
}
]
}

它完美地运行我的代码并完成我所看到的一切。但我在 sublime 控制台上收到一条消息:

# Option "-x" is deprecated and might be removed in a later version of gnome-terminal.
# Use "-- " to terminate the options and put the command line to execute after it.
[Finished in 1.3s]

这是什么意思?如何通过编辑我上面的 sublime 构建来解决这个问题?

【问题讨论】:

    标签: c++ c++14 sublimetext3


    【解决方案1】:

    警告信息是完全不言自明的。在“运行”部分,命令是

    "cmd": ["bash", "-c", "g++ -std=c++14 '${file}' -o '${file_path}/${file_base_name}' && gnome-terminal -x bash -c '\"${file_path}/${file_base_name}\" ; read'"]
    

    && 之后,而不是gnome-terminal -x bash -c ...,只需输入gnome-terminal -- bash -c ... 即可。

    【讨论】:

    • @LiakatHossain 很高兴听到。如果这个答案addressed your problem,请考虑accepting it,点击答案左侧的复选标记/勾选,将其变为绿色。这标志着问题的解决令您满意,并向您和回答者奖励reputation。一旦您拥有 >= 15 的声望点,您也可以根据需要对答案进行投票。也没有义务这样做。
    • 我接受了你的回答。是的,一旦我达到 15 名声望,我就会投票。再次感谢您
    猜你喜欢
    • 2014-04-30
    • 2014-11-18
    • 1970-01-01
    • 2017-10-20
    • 2015-05-07
    • 1970-01-01
    • 2019-04-06
    • 1970-01-01
    • 2018-10-22
    相关资源
    最近更新 更多