Skip to content

Commit c837ae1

Browse files
committed
set stdout and stderr to binary mode on windows
1 parent fca1d53 commit c837ae1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/os.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <windows.h>
2727
#include <io.h>
28+
#include <fcntl.h>
2829

2930
typedef SSIZE_T ssize_t;
3031
#else
@@ -59,7 +60,6 @@ static clock_serv_t cclock;
5960
// implementation in the zig standard library and then this code all gets
6061
// deleted when we self-host. it works for now.
6162

62-
6363
#if defined(ZIG_OS_POSIX)
6464
static void populate_termination(Termination *term, int status) {
6565
if (WIFEXITED(status)) {
@@ -886,6 +886,10 @@ int os_make_dir(Buf *path) {
886886

887887
int os_init(void) {
888888
srand((unsigned)time(NULL));
889+
#if defined(ZIG_OS_WINDOWS)
890+
_setmode(fileno(stdout), _O_BINARY);
891+
_setmode(fileno(stderr), _O_BINARY);
892+
#endif
889893
#if defined(ZIG_OS_WINDOWS)
890894
unsigned __int64 frequency;
891895
if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) {

0 commit comments

Comments
 (0)