diff options
author | adrido <robots_only_adrido@gmx.com> | 2017-04-07 07:14:39 +0200 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-04-07 07:14:39 +0200 |
commit | 676951d90dc7807733288c3c66952bb0394e2e7c (patch) | |
tree | 7428c7503bed28f1afcb391afb2348b6c908acbe /src/porting.cpp | |
parent | 94358a709bdb1fe8101b2b228dec78b67fb377a6 (diff) | |
download | minetest-676951d90dc7807733288c3c66952bb0394e2e7c.tar.gz minetest-676951d90dc7807733288c3c66952bb0394e2e7c.tar.bz2 minetest-676951d90dc7807733288c3c66952bb0394e2e7c.zip |
Windows: Skip cmd for release builds (#5416)
Diffstat (limited to 'src/porting.cpp')
-rw-r--r-- | src/porting.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/porting.cpp b/src/porting.cpp index 4786a2a39..9d859da7d 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -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 |