【发布时间】:2019-09-08 14:50:57
【问题描述】:
我想用MinGW通过Sublime Text编译一个c程序。 我需要运行的命令是:
gcc "${file}" -o "${file_path}\${file_base_name}.exe"
(注意文件路径中的\)
我需要将此字符串写为 JSON 文件中的值。所以,我尝试转换有问题的字符:
" => \"
\ => \\
...
" 字符没有问题,它可以正确转换 - 反斜杠的行为很奇怪。 这是我尝试通过 Sublime 编译时运行的命令:
gcc C:\Users\omer\Desktop${file_base_name}.c -o C:\Users\omer\Desktop${file_base_name}.exe
转换\ => \\不正确?我错过了什么?
编辑:这是完整的构建系统 JSON。
{
"shell_cmd": "gcc \"${file}\" -o \"${file_path}\\${file_base_name}.exe\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c",
"variants":
[
{
"name": "Run",
"shell_cmd": "gcc \"${file}\" -o \"${file_path}\\${file_base_name}.exe\" && \"${file_path}\\${file_base_name}.exe\""
}
]
}
【问题讨论】:
-
您的问题提到知道您需要使用 `\` (这是正确的),但您得到的输出并不反映您这样做了。您能否还包括您的构建系统实际包含的内容?
-
@OdatNurd 在帖子中添加了完整代码。谢谢
标签: json sublimetext3 build-system