[PATCH] Check stdout macro for FILE

Juhani Krekelä juhani at krekela.fi
Wed Jul 6 15:56:15 CEST 2022


# HG changeset patch
# User Juhani Krekelä <juhani at krekelä.fi>
# Date 1657115141 -10800
#      Wed Jul 06 16:45:41 2022 +0300
# Node ID 1b5fa474f6dbe13ead3f8df4ac676425cadce961
# Parent  cc75cab76738fdf96bd0311b943781a86beef49a
Check stdout macro for FILE.

As all C standards to date require stdout to be declared as a macro in
stdio.h, this should be the most portable way to check whether we can use
the FILE type. This change was made to get GMP running on the Sortix
operating system.

The preëxisting checks were left as-is to not break compatibility on other
platforms, but can be removed if a standards-compliant C implementation is
required.

diff -r cc75cab76738 -r 1b5fa474f6db gmp-h.in
--- a/gmp-h.in	Sun Jun 19 15:30:05 2022 +0200
+++ b/gmp-h.in	Wed Jul 06 16:45:41 2022 +0300
@@ -253,6 +253,7 @@
 /* For reference, "defined(EOF)" cannot be used here.  In g++ 2.95.4,
    <iostream> defines EOF but not FILE.  */
 #if defined (FILE)                                              \
+  || defined (stdout)                 /* C89, C99, C11, C17 */  \
   || defined (H_STDIO)                                          \
   || defined (_H_STDIO)               /* AIX */                 \
   || defined (_STDIO_H)               /* glibc, Sun, SCO */     \


More information about the gmp-devel mailing list