I have a build system that runs a build script then executes the program. The problem is that any output the program does is not printed until the application ends.
I tried running the program from the batch script and with the following :
{
"cmd": "build.bat Release & cd bin & .\\editor.exe & cd ..",
"working_dir": "${project_path:${folder}}",
"shell": true,
}
Is there anything to do to avoid this behaviour ?
Here is some simple c++ code that reproduces the problem :
#include <stdio.h>
#include <thread>
int main(int argc, char** argv)
{
using namespace std::chrono_literals;
fprintf(stderr, "Hello, World\n");
std::this_thread::sleep_for(2s);
return 0;
}
EDIT: As OdatNurd pointed it out, calling fflush
in the c++ code does the job. But I would prefer not having to modify my source code to have it work properly with sublime. For me, the tool should adapt to the code, not the other way around.
EDIT2: It appears that this is not happening on Linux, so I guess this is some Windows specific stuff. I updated the title in consequence.