On 6/7/21 5:11 PM, Joseph Myers wrote:
On Sun, 6 Jun 2021, Tom Honermann via Gcc-patches wrote:
When -fchar8_t support is enabled for non-C++ modes, the _CHAR8_T_SOURCE macro
is predefined. This is the mechanism proposed to glibc to opt-in to
declarations of the char8_t typedef and c8rtomb and mbrtoc8 functions proposed
in N2653. See [2].
I don't think glibc should have such a feature test macro, and I don't
think GCC should define such feature test macros either - _*_SOURCE macros
are generally for the *user* to define to decide what namespace they want
visible, not for the compiler to define. Without proliferating new
language dialects, __STDC_VERSION__ ought to be sufficient to communicate
from the compiler to the library (including to GCC's own headers such as
stdatomic.h).
In general I agree, but I think an exception is warranted in this case
for a few reasons:
1. The feature includes both core language changes (the change of type
for u8 string literals) and library changes. The library changes
are not actually dependent on the core language change, but they are
intended to be used together.
2. Existing use of the char8_t identifier can be found in existing open
source projects and likely exists in some closed source projects as
well. An opt-in approach avoids conflict and the need to
conditionalize code based on gcc version.
3. An opt-in approach enables evaluation of the feature prior to any
WG14 approval.
Tom.