Skip to content

Commit

Permalink
Set stdin to binary mode on Windows. Fixes ggerganov#2023
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemdan committed Apr 5, 2024
1 parent 1d7657f commit 2dd5a7f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
#pragma warning(disable: 4244 4267) // possible loss of data
#endif

#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
#endif

// Function to check if the next argument exists
std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) {
if (i + 1 < argc && argv[i + 1][0] != '-') {
Expand Down Expand Up @@ -636,6 +641,10 @@ bool read_wav(const std::string & fname, std::vector<float>& pcmf32, std::vector

if (fname == "-") {
{
#ifdef _WIN32
_setmode(_fileno(stdin), _O_BINARY);
#endif

uint8_t buf[1024];
while (true)
{
Expand Down

0 comments on commit 2dd5a7f

Please sign in to comment.