Skip to content

Commit d3cfb6c

Browse files
authored
main : set stdin to binary mode on Windows (ggml-org#2025)
1 parent 956ef86 commit d3cfb6c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/common.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
#pragma warning(disable: 4244 4267) // possible loss of data
2020
#endif
2121

22+
#ifdef _WIN32
23+
#include <fcntl.h>
24+
#include <io.h>
25+
#endif
26+
2227
// Function to check if the next argument exists
2328
std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) {
2429
if (i + 1 < argc && argv[i + 1][0] != '-') {
@@ -636,6 +641,10 @@ bool read_wav(const std::string & fname, std::vector<float>& pcmf32, std::vector
636641

637642
if (fname == "-") {
638643
{
644+
#ifdef _WIN32
645+
_setmode(_fileno(stdin), _O_BINARY);
646+
#endif
647+
639648
uint8_t buf[1024];
640649
while (true)
641650
{

0 commit comments

Comments
 (0)