Skip to content

Commit

Permalink
set stdout and stderr to binary mode on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Oct 15, 2017
1 parent fca1d53 commit c837ae1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <windows.h>
#include <io.h>
#include <fcntl.h>

typedef SSIZE_T ssize_t;
#else
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit c837ae1

Please sign in to comment.