How do I run C 11 in Sublime Text 3?
I found this and this works, but I want it to be able to open cmd each run.
(1)
{
"shell_cmd": "g -std=c 11 \"${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",
"shell_cmd": "g -std=c 11 \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
]
}
Like this one: (2)
{
"cmd":
[
"g ", "-Wall", "-ansi", "-pedantic-errors", "$file_name", "-o",
"${file_base_name}.exe", "&&", "start",
"cmd", "/k" , "$file_base_name"
],
"selector": "source.cpp",
"working_dir": "${file_path}",
"shell": true
}
The problem with (1) is it runs with the console inside Sublime Text 3, I don't want that, unfortunately. The problem with (2) is it runs well and it opens CMD each time, which is what I need, but it's on C 98. When I need C 11.
So, is there a way to modify any one of these build systems so that I can run C 11 and make it open CMD every run (instead of running it on the console)? Thanks.
CodePudding user response:
I was able to figure it out with a little bit of tinkering involved.
{
"shell_cmd": "g -std=c 11 \"${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",
"shell_cmd": "g -std=c 11 \"${file}\" -o \"${file_path}/${file_base_name}\" && start cmd /k \"${file_path}/${file_base_name}\""
}
]
}