Skip to content

Commit

Permalink
bin2c: Add O_BINARY for mingw-w64-i686
Browse files Browse the repository at this point in the history
  • Loading branch information
F0bes committed Oct 19, 2024
1 parent d1818f4 commit 3d74e9b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/bin2c/src/bin2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
#include <stdio.h>
#include <string.h>

// mingw-w64-x86_64 works fine without the binary flag
// mingw-w64-i686 needs the binary flag
#ifndef O_BINARY
#define O_BINARY 0
#endif

const char *const hex_lut[256] =
{
"0x00, ", "0x01, ", "0x02, ", "0x03, ", "0x04, ", "0x05, ", "0x06, ", "0x07, ", "0x08, ", "0x09, ", "0x0a, ", "0x0b, ", "0x0c, ", "0x0d, ", "0x0e, ", "0x0f, ",
Expand Down Expand Up @@ -55,7 +61,7 @@ int main(int argc, char *argv[])
return 1;
}

if ((src_fd = open(argv[1], O_RDONLY, (mode_t)0600)) == -1)
if ((src_fd = open(argv[1], O_RDONLY | O_BINARY, (mode_t)0600)) == -1)
{
printf("Error opening %s for reading.\n", argv[1]);
return 1;
Expand Down

0 comments on commit 3d74e9b

Please sign in to comment.