Browse files

test-genrandom: ensure stdout is set to _O_BINARY on Windows

Commit a6ca8c6 (Set _O_BINARY as default fmode for both MinGW and MSVC)
removed the definition of _CRT_fmode from mingw.c. Before this commit,
since test-genrandom is linked against libgit.a, the MinGW process
initialization code would pick up that definition of _CRT_fmode, which was
initialized to _O_BINARY. After this commit, however, text mode is used
for std(in|out|err) because it is the default in absence of _CRT_fmode.
In order to fix that, we must use git-compat-util.h, which overrides
main() to set the mode to binary.

Signed-off-by: Johannes Sixt <>
Signed-off-by: Junio C Hamano <>
  • Loading branch information...
1 parent 0984e3a commit a16753dc2e6f885fd30e570610c3e8cf355ecf04 @j6t j6t committed with gitster Sep 21, 2009
Showing with 1 addition and 2 deletions.
  1. +1 −2 test-genrandom.c
3 test-genrandom.c
@@ -4,8 +4,7 @@
* Copyright (C) 2007 by Nicolas Pitre, licensed under the GPL version 2.
-#include <stdio.h>
-#include <stdlib.h>
+#include "git-compat-util.h"
int main(int argc, char *argv[])

0 comments on commit a16753d

Please sign in to comment.