[PATCH 2/2] ctype: use less short names in public header

Jonathan Wakely jwakely@redhat.com
Tue Nov 30 12:01:48 GMT 2021

On 23/11/21 23:15 -0500, Mike Frysinger wrote:
>On 23 Nov 2021 15:09, Richard Earnshaw wrote:
>> This is wrong and breaks all old versions of C++.
>this is a bit vague.  it would help if you provided details as to what broke.
>i doubt this broke all old versions of C++ everywhere.
>i'm guessing you're referring to the GNU C++ (libstdc++) library specifically
>and its hardcoding of newlib's internal ctype define names.

Yes, you were CC'd on the GCC bug slightly before Richard sent his
email to this list:

>if you're talking about something else, please state so clearly.
>> The GNU sim code should not be using reserved names (those starting _)
>> in normal source code.  Such names are reserved to the implementation.
>that's not really a good reason to go pooping all over the namespace.
>we can maintain backwards compat here for C++ code fairly easily:

Yes, or only do that for GCC < 12, as I suggested in

#if defined(__GNUC__) && defined(__cplusplus)
# if __GNUC__ < 12

The libstdc++ code on trunk uses the new _ISupper names.

I have no opinion on how long you should keep such backwards
compatibility around. Whatever time limit you set, at some point it
will make a new newlib release unusable with past G++ versions.

But either way, the GNU sim code needed to be fixed. Your commit msg
for that was misleading:

     Some C libraries export _P symbols in their headers (like older
     newlib and its ctype.h), so use P_ instead to avoid conflicts.

It's irrelevant whether they use it or not: _P is a reserved name
meaning they *could* use it, and so anything outside "the
implementation" MUST NOT use it.

This isn't "that particular name happens to clash with a particular
header", it's "that name causes undefined behaviour, period".

More information about the Newlib mailing list