Re: _ISOCxx_SOURCE
Alejandro Colomar <[email protected]> Tue, 16 Jun 2026 23:11:48 +0200
| Newsgroups | org.kernel.vger.linux-man |
|---|---|
| Message-ID | <ajG7DCFNQPXb11nr@devuan> |
Hi Joseph,
On 2026-06-16T16:02:44+0000, Joseph Myers wrote:
> On Mon, 15 Jun 2026, Alejandro Colomar wrote:
>
> > Hi Joseph,
> >
> > On 2026-06-15T17:20:17+0000, Joseph Myers wrote:
> > > On Sat, 13 Jun 2026, Alejandro Colomar via Gcc wrote:
> > >
> > > > I was reviewing the feature_test_macros(7) page, and found the
> > > > documentation of the _ISOC{99,11,23,...}_SOURCE macros to be incorrect.
> > > > And thinking about fixing that led me to think that the design of those
> > > > macros is less than ideal.
> > >
> > > Users should normally use -std= options with the compiler to get matching
> > > language and library features. These feature test macros are mainly for
> > > niche cases with old compilers. So I don't think any new user-facing
> > > design for them should be added (the C23 and later ones already use the
> > > newer __GLIBC_USE style of conditionals in the header implementation).
> >
> > Makes sense. Should I document that users should avoid setting them
> > directly (and that they should use the corresponding compiler flag)?
>
> Indeed.
Thanks! Will do.
> Also, users are probably using a compiler defaulting to
> -std=gnu23 or -std=gnu11 so the older _ISOC99_SOURCE and _ISOC11_SOURCE
> are doubly irrelevant for that reason.
I was also wondering...
If one uses a modern GCC with an old glibc (which doesn't know C23),
then, using -std=c23 will be problematic: the compiler will enable C23
language mode, but the library will entirely and silently ignore
_ISOC23_SOURCE, because it doesn't know about it, thus falling back to
C89 mode (I guess), and thus will for example enable things like
gets(3).
If the way to pass the language version from the compiler to the libc
were through a single macro, then the library would be able to at least
diagnose, and/or turn on the latest dialect it knows about.
Is there any limitation of which libc versions are supported by modern
GCC? Is this a bug?
Have a lovely night!
Alex
>
> --
> Joseph S. Myers
> [email protected]
>
--
<https://www.alejandro-colomar.es>
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmoxvA4ACgkQ64mZXMKQ wqkzVQ/+NJ8hHaPbImtle/t+FAP4aY37eY0Id5tuI/VsAZb1WLmHFeTgscifC6D8 suY/vCbVFh6SPtc2wwutVRUo68ZpqsedYG5nMCYdpeIyNePO1xhEnq1aHI7xl2iB StirtfyhAz0kBI0Uri0mJSLzkXf6AUXNMtZgIacDUU1ICMGCGr022ufKVu3FP502 PDAVBmmJA4YZgxcJNtfv/6hIkFJ2MXKAU0P9VgqhrbYPlLGJEP+jfQfJUVoX7fvi efa+miGrve6pIQxhRvEaLTP1xLUdTfel3LYkHRbPACHMGWwqiXsry5++1j4S4Gx4 05Otgp4g4Yok4OwZxG+6PG3tM3qVWzW0qPeuxrqTgspqCAtbfk3CklPUmOLOzMka MD91kNrGw1H1FXzUDcGf+aXoQW+qvtNy6DnKNAlTyPyyh8dmk05VJeLVki1ZJF+c zNGN4iFWuTuD7wyXq3SrzK+S4ZniqDAKypL52ueaeaxc6s+h3et4Q6HBzqH0HMFB yTnMCxTCU8GqEpLqp4IzWQsrB3lxmyGRDCCpoQzuv9sHxfoIelf41uUKarTasKj3 zSJtvH2IR7PXkEL7UZ3ZNDQPnXCfPuZYvR24easWqm+/MiYmTzupq2mHvs7G8v6o 22CLg6QlXgT0e656Kb6ioC5TdUvYMjzEhqIWKmXNnokkbpgd39U= =8oAN -----END PGP SIGNATURE-----