我正在使用 Windows 7 并且我已经添加了
{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe", "-lm", "-Wall"],
"selector" : "source.c",
"shell":true,
"working_dir" : "$file_path"
}
我的 c.sublime-build 虽然它可以构建我的程序,但运行选项消失了。所以我看不到简单的 hello world 程序的输出。
最佳答案
您需要添加一个 variant对于将执行程序的 Run
选项。这是我的 g++.sublime-build 的样子
{
"shell_cmd": "g++ \"${file}\" -O3 -std=c++11 -pedantic -Wall -Wextra -Wconversion -o \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ \"${file}\" -O3 -std=c++11 -pedantic -Wall -Wextra -Wconversion -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
]
}
我的 Run 选项构建并运行程序,如果您只希望它运行可执行文件,则删除命令的前半部分。
关于c - sublime text 2 无法运行我的 c 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21922653/