[PATCH 1/3] include/binary-io.h: guard O_BINARY usage with defined check

Andrew Hanson andrew@andrewhanson.dev
Sun Sep 14 19:52:45 GMT 2025


Fixes -Wundef compiler warning when O_BINARY is not defined. Wrap the check
to ensure portability across platforms.
---
 include/binary-io.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/binary-io.h b/include/binary-io.h
index 2f4be43a7c1..33f5173636f 100644
--- a/include/binary-io.h
+++ b/include/binary-io.h
@@ -34,6 +34,10 @@
   /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect.  */
 # undef O_BINARY
 # undef O_TEXT
+#endif
+  /* If O_BINARY is not defined, provide a harmless default. */
+#ifndef O_BINARY
+# define O_BINARY 0
 #endif
 #if O_BINARY
 # if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
-- 
2.51.0



More information about the Binutils mailing list