[1/3] include/binary-io.h: guard O_BINARY usage with defined check
Commit Message
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(+)
Comments
On 14.09.2025 21:52, Andrew Hanson wrote:
> 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__
It feels a little odd to define it to 0, just for it to then be
undef-ed again, to then be defined to 0 again. Imo it would be
more logical to change the #if line to include a defined() check.
Thoughts?
Jan
@@ -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__