[PATCH] Fix _GMP_H_HAVE_FILE detection on recent FreeBSD
Dimitry Andric
dim at FreeBSD.org
Sun Aug 16 18:36:32 CEST 2026
In FreeBSD 16-CURRENT, some work has been ongoing to improve C23
support. As part of this, the FreeBSD stdio.h header has been changed to
longer define the macro _STDIO_H_, but to define the C23 standard macro
__STDC_VERSION_STDIO_H__ instead (with numeric value 202311L).
This causes the math/gmp port to fail to compile, because gmp.h can no
longer detect that FILE has been declared, leading to _GMP_H_HAVE_FILE
being unset. It typically shows as the following error:
inp_str.c:63:10: warning: call to undeclared function
'__gmpz_inp_str_nowhite'; ISO C99 and later do not support implicit
function declarations [-Wimplicit-function-declaration]
63 | return mpz_inp_str_nowhite (x, stream, base, c, nread);
| ^
../gmp-impl.h:1782:29: note: expanded from macro 'mpz_inp_str_nowhite'
1782 | #define mpz_inp_str_nowhite __gmpz_inp_str_nowhite
| ^
inp_str.c:68:1: error: conflicting types for '__gmpz_inp_str_nowhite'
68 | mpz_inp_str_nowhite (mpz_ptr x, FILE *stream, int base, int c,
size_t nread)
| ^
../gmp-impl.h:1782:29: note: expanded from macro 'mpz_inp_str_nowhite'
1782 | #define mpz_inp_str_nowhite __gmpz_inp_str_nowhite
| ^
inp_str.c:63:10: note: previous implicit declaration is here
63 | return mpz_inp_str_nowhite (x, stream, base, c, nread);
| ^
../gmp-impl.h:1782:29: note: expanded from macro 'mpz_inp_str_nowhite'
1782 | #define mpz_inp_str_nowhite __gmpz_inp_str_nowhite
| ^
1 warning and 1 error generated.
For the FreeBSD port I have proposed a diff similar to the following. In
this version, I have adjusted the whitespace in the comments to line up
vertically. This is against changeset: 18574:b4d0ee7d9773.
diff -r b4d0ee7d9773 gmp-h.in
--- a/gmp-h.in Sun Jul 26 11:54:09 2026 +0200
+++ b/gmp-h.in Sun Aug 16 18:25:57 2026 +0200
@@ -254,21 +254,22 @@
<iostream> defines EOF but not FILE. */
#if defined (FILE) \
|| defined (H_STDIO) \
- || defined (_H_STDIO) /* AIX */ \
- || defined (_STDIO_H) /* glibc, Sun, SCO */ \
- || defined (_STDIO_H_) /* BSD, OSF */ \
- || defined (__STDIO_H) /* Borland */ \
- || defined (__STDIO_H__) /* IRIX */ \
- || defined (_STDIO_INCLUDED) /* HPUX */ \
- || defined (__dj_include_stdio_h_) /* DJGPP */ \
- || defined (_FILE_DEFINED) /* Microsoft */ \
- || defined (__STDIO__) /* Apple MPW MrC */ \
- || defined (_MSL_STDIO_H) /* Metrowerks */ \
- || defined (_STDIO_H_INCLUDED) /* QNX4 */ \
- || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \
- || defined (__STDIO_LOADED) /* VMS */ \
- || defined (_STDIO) /* HPE NonStop */ \
- || defined (__DEFINED_FILE) /* musl */
+ || defined (_H_STDIO) /* AIX */ \
+ || defined (_STDIO_H) /* glibc, Sun, SCO */ \
+ || defined (_STDIO_H_) /* BSD, OSF */ \
+ || defined (__STDIO_H) /* Borland */ \
+ || defined (__STDIO_H__) /* IRIX */ \
+ || defined (_STDIO_INCLUDED) /* HPUX */ \
+ || defined (__dj_include_stdio_h_) /* DJGPP */ \
+ || defined (_FILE_DEFINED) /* Microsoft */ \
+ || defined (__STDIO__) /* Apple MPW MrC */ \
+ || defined (_MSL_STDIO_H) /* Metrowerks */ \
+ || defined (_STDIO_H_INCLUDED) /* QNX4 */ \
+ || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \
+ || defined (__STDIO_LOADED) /* VMS */ \
+ || defined (_STDIO) /* HPE NonStop */ \
+ || defined (__DEFINED_FILE) /* musl */ \
+ || defined (__STDC_VERSION_STDIO_H__) /* C23 */
#define _GMP_H_HAVE_FILE 1
#endif
diff -r b4d0ee7d9773 mini-gmp/mini-mpq.h
--- a/mini-gmp/mini-mpq.h Sun Jul 26 11:54:09 2026 +0200
+++ b/mini-gmp/mini-mpq.h Sun Aug 16 18:25:57 2026 +0200
@@ -90,19 +90,22 @@
<iostream> defines EOF but not FILE. */
#if defined (FILE) \
|| defined (H_STDIO) \
- || defined (_H_STDIO) /* AIX */ \
- || defined (_STDIO_H) /* glibc, Sun, SCO */ \
- || defined (_STDIO_H_) /* BSD, OSF */ \
- || defined (__STDIO_H) /* Borland */ \
- || defined (__STDIO_H__) /* IRIX */ \
- || defined (_STDIO_INCLUDED) /* HPUX */ \
- || defined (__dj_include_stdio_h_) /* DJGPP */ \
- || defined (_FILE_DEFINED) /* Microsoft */ \
- || defined (__STDIO__) /* Apple MPW MrC */ \
- || defined (_MSL_STDIO_H) /* Metrowerks */ \
- || defined (_STDIO_H_INCLUDED) /* QNX4 */ \
- || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \
- || defined (__STDIO_LOADED) /* VMS */
+ || defined (_H_STDIO) /* AIX */ \
+ || defined (_STDIO_H) /* glibc, Sun, SCO */ \
+ || defined (_STDIO_H_) /* BSD, OSF */ \
+ || defined (__STDIO_H) /* Borland */ \
+ || defined (__STDIO_H__) /* IRIX */ \
+ || defined (_STDIO_INCLUDED) /* HPUX */ \
+ || defined (__dj_include_stdio_h_) /* DJGPP */ \
+ || defined (_FILE_DEFINED) /* Microsoft */ \
+ || defined (__STDIO__) /* Apple MPW MrC */ \
+ || defined (_MSL_STDIO_H) /* Metrowerks */ \
+ || defined (_STDIO_H_INCLUDED) /* QNX4 */ \
+ || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \
+ || defined (__STDIO_LOADED) /* VMS */ \
+ || defined (_STDIO) /* HPE NonStop */ \
+ || defined (__DEFINED_FILE) /* musl */ \
+ || defined (__STDC_VERSION_STDIO_H__) /* C23 */
size_t mpq_out_str (FILE *, int, const mpq_t);
#endif
-Dimitry
More information about the gmp-devel
mailing list