你好,我在 Sublime Text 3 中搞砸了一些 C++ 构建系统,现在我无法运行任何程序。 这是我的构建系统:
{
"cmd": "g++ \"${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": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && open -a Terminal -e \"${file_path}/${file_base_name}\""
}
]
}
感谢您的帮助, 内诺尔
最佳答案
唯一错误的想法似乎是您编写命令
的方式。新文档中没有说明,但在 old one 中说明了这一点。你可以阅读
命令: 数组包含要运行的命令及其所需的参数。
所以,这个构建系统应该可以解决问题(这是默认提供的):
{
"cmd": ["g++", "${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++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
请注意,之前有人报告过默认提供的 C++.sublime-build
遇到问题(在我的 OS X 上一切正常)。如果是这种情况,请考虑 salek 在 this answer 上的回复.
关于c++ - Sublime Text 3 C++ 构建系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19228583/