From c662042a60293466bb64825461b04e71ca10486e Mon Sep 17 00:00:00 2001 From: Jonah Beckford <71855677+jonahbeckford@users.noreply.github.com> Date: Thu, 22 Jun 2023 12:11:03 -0700 Subject: [PATCH] Read schemas in binary on Windows --- compiler/capnpc-c.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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;