1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Windows: Skip cmd for release builds (#5416)

This commit is contained in:
adrido 2017-04-07 07:14:39 +02:00 committed by Loïc Blot
parent 94358a709b
commit 676951d90d
6 changed files with 42 additions and 7 deletions

View file

@ -929,4 +929,18 @@ bool secure_rand_fill_buf(void *buf, size_t len)
#endif
void attachOrCreateConsole(void)
{
#ifdef _WIN32
static bool consoleAllocated = false;
const bool redirected = (_fileno(stdout) == -2 || _fileno(stdout) == -1); // If output is redirected to e.g a file
if (!consoleAllocated && redirected && (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole())) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
consoleAllocated = true;
}
#endif
}
} //namespace porting