1

编译 C++ 源代码后,我想通过 sublime text 命令使用输入文件运行它。如何才能做到这一点?

4

1 回答 1

2

如果您的意思是 C++ 构建文件之后的参数,我已经找到了一种方法来以一种狡猾的方式做到这一点......我为 c++11 创建了一个新的构建系统并将输入文件(参见下面的 input_file)添加到运行部分。

{
"cmd": ["g++", "-Wall", "-Wextra", "-pedantic", "-std=c++0x",   "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",

"variants":
[
    {
        "name": "Run",
        "cmd": ["bash", "-c", "g++ -Wall -Wextra -pedantic -std=c++0x '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}' input_file"]
    }
]}

保存文件,例如C++11.sublime-build,在$HOME/.config/sublime-text-2/Packages/User. 选择 Build System C++11,它应该可以完成这项工作。

于 2013-04-05T12:17:44.270 回答