On Sun, 13 Aug 2023 at 21:15, Arsen Arsenović via Libstdc++
<libstd...@gcc.gnu.org> wrote:
>
> This commit replaces the ad-hoc logic in <version> with an AutoGen
> database that (mostly) declaratively generates a version.h bit which
> combines all of the FTM logic across all headers together.
>
> This generated header defines macros of the form __glibcxx_foo,
> equivalent to their __cpp_lib_foo variants, according to rules specified
> in version.def and, optionally, if __glibcxx_want_foo or
> __glibcxx_want_all are defined, also defines __cpp_lib_foo forms with
> the same definition.
>
> libstdc++-v3/ChangeLog:
>
>         * include/Makefile.am (bits_freestanding): Add version.h.
>         (allcreated): Add version.h.
>         (${bits_srcdir}/version.h): New rule.  Regenerates
>         version.h out of version.{def,tpl}.
>         * include/Makefile.in: Regenerate.
>         * include/bits/version.def: New file.  Declares a list of
>         all feature test macros, their values and their preconditions.
>         * include/bits/version.tpl: New file.  Turns version.def
>         into a sequence of #if blocks.
>         * include/bits/version.h: New file.  Generated from
>         version.def.
>         * include/std/version: Replace with a __glibcxx_want_all define
>         and bits/version.h include.


I still don't love this change, due to the added overhead in
preprocessing time. I also don't understand the Guile code in the
autogen template, but that's OK too.

But defining them all in one place, in a consistent form, is
definitely an improvement, so that the macros in <version> are always
consistent with other headers.  And not having the definitions
scattered around various headers is probably much easier for most
maintainers to follow.

I think it's a net improvement, so OK for trunk. Thanks for working on this.

I wonder why we only define __cpp_lib_null_iterators for >= C++14. It
was a C++14 change, but in practice it Just Works even in C++98 mode.
We don't have any code pre-C++14 that makes it *not* work (except
debug mode). We should revisit that.

Reply via email to