[PATCH] Fix _GMP_H_HAVE_FILE detection on recent FreeBSD
Marc Glisse
marc.glisse at inria.fr
Mon Aug 17 11:45:43 CEST 2026
On Sun, 16 Aug 2026, Dimitry Andric wrote:
> 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).
>
[...]
>
> For the FreeBSD port I have proposed a diff similar to the following.
Hello,
thanks for the report.
I looked at C23 (or drafts from before/after), and it isn't clear to me
how safe this is. As far as I understand (and I may be completely wrong),
the guarantees are
* After including <stdio.h>, __STDC_VERSION_STDIO_H__ is defined to
202311L.
* If __STDC_VERSION_STDIO_H__ is 202311L, after including <stdio.h>, I'll
have access to the C23 functionality.
I think an implementation is allowed to predefine __STDC_VERSION_STDIO_H__
(and all the other similar macros) at startup, which would break this
detection mechanism. Maybe we could reduce this risk by checking (defined
(__STDC_VERSION_STDIO_H__) && defined (FOPEN_MAX)) or some other macro
that stdio.h must provide?
(I thought there were 3 copies of that list of macros, I'll check when I
apply it)
--
Marc Glisse
More information about the gmp-devel
mailing list