Previous standards had reserved identifiers according to for example C17 7.1.3:
- All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use, except those identifiers which are lexically identical to keywords.
- All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
In addition, lots of special cases existed in "future library directions".
But in C23 I only find this unhelpful text instead (C23 7.1.3):
- All potentially reserved identifiers (including ones listed in the future library directions) that are provided by an implementation with an external definition are reserved for any use. An implementation shall not provide an external definition of a potentially reserved identifier unless that identifier is reserved for a use where it would have external linkage. All other potentially reserved identifiers that are provided by an implementation (including in the form of a macro) are reserved for any use when the associated header is included. No other potentially reserved identifiers are reserved.
(Future library directions remains roughly the same as before.)
As usual, the C23 editor forgot to update Annex J:
- (105) The program declares or defines a reserved identifier, other than as allowed by 7.1.4 (7.1.3).
- (106) The program removes the definition of a macro whose name begins with an underscore and either an uppercase letter or another underscore (7.1.3).
How am I to make any sense of this? Is this too one big editing mistake or have the use of reserved identifiers changed?
This was changed in C23 as per proposals n2625 and n2762. The rules are pretty much the same but now instead found in C23 Chapter 6.4.3 Identifiers:
Some identifiers are reserved.
- All identifiers that begin with a double underscore (
__
) or begin with an underscore (_
) followed by an uppercase letter are reserved for any use, except those identifiers which are lexically identical to keywords.- All identifiers that begin with an underscore are reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
Other identifiers may be reserved, see 7.1.3.
As for Annex J, it was an editorial fiasco before C23 and remains an even bigger fiasco after C23. It should be ignored entirely since large parts of it is misleading and incorrect. Needs substantial technical corrigendum.