Request to all Sublime text 3 competitive coders

I am using this build function in windows 10

{
“shell_cmd”: "g++ -std=c++17 “{file}\" -o \"{file_path}/{file_base_name}\" && \"{file_path}/{file_base_name}\" && timeout /t 0.5", "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)”,
“working_dir”: “${file_path}”,
“selector”: “source.c, source.c++”,
“variants”:
[

   {
     "name": "Run",
    "shell_cmd": "g++ -std=c++17 \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\" && timeout /t 0.5"
   }
 ]

}

IT GIVES ME AN ERROR OF
ERROR: Invalid value for timeout (/T) specified. Valid range is -1 to 99999.

PLEASE ANYONE TELL ME HOW TO CORRECT THIS ???

PS:- I am using timeout function which automatically break when program execute more than 0.5sec

Try changing the timeout to 1 or 2, then try building it again.

If i changed to time limit to >=1 sec then it gives error like this:->

ERROR: Input redirection is not supported, exiting the process immediately.

I don’t use the timeout function and the rest of the build settings is the same as yours and it works fine.
PS:- I have been using another build settings lately for input and output file which I read from a blog from CodingBlocks.

But brother what you will do if your program goes in inifinite loops??? and then suddenly hang your window???
PS:- During competition this will occur with me due to that i waste a lot of time

Well I try to first analyze the complexity of my program and then code the solution and if there is an infinite loop just use the task manager to kill the program.
I’ll try your settings tomorrow and then try to fix it. I cannot assure you tho.

{
“cmd”: [“g++.exe”,"-std=c++17", “{file}", "-o", "{file_base_name}.exe”, “&&” , “${file_base_name}.exe<input.txt>output.txt”],
“shell”:true,
“working_dir”:"$file_path",
“selector”:“source.cpp”
}

Use this for c++17 ,
for c++ 14 just replace “c++17” with “c++14”.
just replace “input.txt” and “output.txt” with your input , output file name.

Hopefully this will help you.

Bro see this

The build given by him is only works in Linux and i am using windows OS

Bro suppose you code goes in infinite loop then your system will hang!!! , i tried to break the execution after 0.5 seconds

I tried to fix it but it seems the best way to stop the execution is to cancel the build.
Just change the preferences as described here.
There is nothing I could find that could just limit the time for the build/execution.
Whenever your code takes more than six seconds just use the cancel build option to immediately terminate it.

1 Like

In Sublime Text, the default option to cancel build is ctrl+break.If your system does not have break button then go to preferences->key bindings and in the right column of window type:
[
{ “keys”: [“ctrl+alt+b”], “command”: “cancel_build” }
]
and save it or any other shortcut you like.
I faced this problem many times earlier but now i can just press ctrl+alt+b and it cancels build and can continue with program like nothing happened.

NO BUILD SYSTEM …SEE in the buttom of SS . i have done same as you have written.but still

Can the same sublime text be also setup for java alongwith user input of test cases?
If yes please do tell

@lovlesh_007 Did you get an answer to your question? I am having the same issue. I don’t think that timeout is recognized as an command by the windows system. So this timeout trick would only work in linux. Nevertheless, if you got a solution can you share it with me.

2 Likes