Commit c837ae1707

Andrew Kelley <superjoe30@gmail.com>
2017-10-16 00:25:39
set stdout and stderr to binary mode on windows
1 parent fca1d53
Changed files (1)
src
src/os.cpp
@@ -25,6 +25,7 @@
 
 #include <windows.h>
 #include <io.h>
+#include <fcntl.h>
 
 typedef SSIZE_T ssize_t;
 #else
@@ -59,7 +60,6 @@ static clock_serv_t cclock;
 // implementation in the zig standard library and then this code all gets
 // deleted when we self-host. it works for now.
 
-
 #if defined(ZIG_OS_POSIX)
 static void populate_termination(Termination *term, int status) {
     if (WIFEXITED(status)) {
@@ -886,6 +886,10 @@ int os_make_dir(Buf *path) {
 
 int os_init(void) {
     srand((unsigned)time(NULL));
+#if defined(ZIG_OS_WINDOWS)
+    _setmode(fileno(stdout), _O_BINARY);
+    _setmode(fileno(stderr), _O_BINARY);
+#endif
 #if defined(ZIG_OS_WINDOWS)
     unsigned __int64 frequency;
     if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) {