What's the meaning of "reserved for any use"?

In the C standard, the meaning of the term "reserved" is defined by 7.1.3p2, immediately below the bullet list you are quoting:

No other identifiers are reserved. If the program declares or defines an identifier in a context in which it is reserved (other than as allowed by 7.1.4), or defines a reserved identifier as a macro name, the behavior is undefined.

Emphasis mine: reserved identifiers place a restriction on the program, not the implementation. Thus, the common interpretation – reserved identifiers may be used by the implementation to any purpose – is correct for C.

I have not kept up with the C++ standard and no longer feel qualified to interpret it.


While the Standard is primarily written to guide implementers, it is written as a description of what makes a program well-formed, and what its effect is. That's because the basic definition of a standards-conforming compiler is one that does the correct thing for any standards-conforming program:

A strictly conforming program shall use only those features of the language and library specified in this International Standard....A conforming hosted implementation shall accept any strictly conforming program.

Read separately, this is hugely restrictive of extensions to a compiler. For instance, based solely on that clause, a compiler shouldn't get to define any of its own reserved words. After all, any given word a particular compiler might want to reserve, could nevertheless show up in a strictly conforming program, forcing the compiler's hand.

The standard goes on, however:

A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any strictly conforming program.

That's the key piece. Compiler extensions need to be written in such a way that they affect nonconforming programs (ones which contain undefined behavior, or which shouldn't even compile at all), allowing them to compile and do fun extra things.

So the purpose of defining "reserved identifiers", when the language doesn't actually need those identifiers for anything, is to give implementations some extra wiggle room by providing them with some things which make a program nonconforming. The reason a compiler can recognize, say, __declspec as part of a declaration is because putting __declspec into a declaration is otherwise illegal, so the compiler is allowed to do whatever it wants!

The importance of "reserved for any use", therefore, is that it leaves no question about a compiler's power to treat such identifiers as having any meaning it cares to. Future compatibility is a comparatively distant concern.

The C++ standard works in a similar way, though it's a bit more explicit about the gambit:

A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any well-formed program. Implementations are required to diagnose programs that use such extensions that are ill-formed according to this International Standard. Having done so, however, they can compile and execute such programs.

I suspect the difference in wording is down to the C++ standard just being clearer about how extensions are meant to work. Nevertheless, nothing in the C standard precludes an implementation from doing the same thing. (And we all basically ignore the requirement that the compiler warn you every time you use __declspec.)


Regarding the difference in wording in C versus C++, I'm posting my own little research here as reference:

  • The early K&R C 1st edition has this text:

    ...names which are intended for use only by functions of the library begin with an underscore so they are less likely to collide with names in a user's program.

  • K&R 2nd edition added an Appendix B which addresses the standard library, where we can read

    External identifiers that begin with an underscore are reserved for use by the library, as are all other identifiers that begin with an underscore and an upper-case letter or another underscore.

  • Early ANSI C drafts, as well as "C90" ISO 9899:1990, has the same text as in the current ISO standard.

  • The earliest C++ drafts however, has a different text, as noted by @hvd, possibly a clarification of the C standard. From DRAFT: 20 September 1994:

    17.3.3.1.2 Global names
    ...
    Each name that begins with an underscore and either an uppercase letter or another underscore (2.8) is reserved to the implementation for any use

So apparently the wording "reserved for any use" was invented by the ANSI/ISO C90 committee, whereas the C++ committee some years later used a clearer wording, similar to the that in the pre-standard K&R book.


The C99 rationale V5.10 says this below 7.1.3:

Also reserved for the implementor are all external identifiers beginning with an underscore, and all other identifiers beginning with an underscore followed by a capital letter or an underscore. This gives a name space for writing the numerous behind-the-scenes non-external macros and functions a library needs to do its job properly.

This makes the committee's intention quite clear: "reserved for any use" means "reserved for the implementor".


Also of note, the current C standard has the following normative text elsewhere, in 6.2.5:

There may also be implementation-defined extended signed integer types. 38)

where the informative foot note 38 says:

38) Implementation-defined keywords shall have the form of an identifier reserved for any use as described in 7.1.3.