diff --git a/compiler/capnpc-c.c b/compiler/capnpc-c.c index 3babd2e..649690f 100644 --- a/compiler/capnpc-c.c +++ b/compiler/capnpc-c.c @@ -14,6 +14,10 @@ #include #include #include +#ifdef _WIN32 +#include +#include +#endif struct value { struct Type t; @@ -1317,6 +1321,14 @@ int main() { uint64_t total_len=0; struct capn_segment *current_seg; +#ifdef _WIN32 + /* schemas need to be read in binary mode, not default text mode */ + if(_setmode(_fileno( stdin ), _O_BINARY)==-1) { + fprintf(stderr, "failed to set stdin to binary mode\n"); + return -1; + } +#endif + if (capn_init_fp(&capn, stdin, 0)==-1) { fprintf(stderr, "failed to read schema from stdin\n"); return -1;