From 0ae2207e8c9655bee57d8ccb3a1a31d0e0d88cd7 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sat, 26 Dec 2015 00:50:22 +0100 Subject: [PATCH] -Fix: [Win32] Stdin/out/err need to be re-assigned differently if the runtime lib of MSVC2015 is used. --- src/os/windows/win32.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 2682fa1..041468a 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -338,9 +338,16 @@ void CreateConsole() return; } +#if defined(_MSC_VER) && _MSC_VER >= 1900 + freopen("CONOUT$", "a", stdout); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "a", stderr); +#else *stdout = *_fdopen(fd, "w"); *stdin = *_fdopen(_open_osfhandle((intptr_t)GetStdHandle(STD_INPUT_HANDLE), _O_TEXT), "r" ); *stderr = *_fdopen(_open_osfhandle((intptr_t)GetStdHandle(STD_ERROR_HANDLE), _O_TEXT), "w" ); +#endif + #else /* open_osfhandle is not in cygwin */ *stdout = *fdopen(1, "w" ); -- 2.6.4.windows.1