【发布时间】:2013-04-05 09:20:20
【问题描述】:
C++ 源代码编译后,我想通过 sublime text 命令使用输入文件运行它。如何做到这一点?
【问题讨论】:
-
在project settings中设置一个合适的build system?
标签: c++ sublimetext2
C++ 源代码编译后,我想通过 sublime text 命令使用输入文件运行它。如何做到这一点?
【问题讨论】:
标签: c++ sublimetext2
如果你的意思是你的 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,它应该可以完成这项工作。
【讨论】: