Namespace Reservation for the C Standard

WG 14 Document numberN1345
ProjectProgramming Language C
ReferenceISO/IEC IS 9899:1999
Reply toNick Stoughton
USENIX Association


Several recent proposals for the C1x revision have introduced new keywords, functions, or macros that require the implementation to "do the dance": the keyword (function or macro) is actually named _[UpperCaseChar]name, and a header is required to define the natural spelling of the keyword. For example, _Thread_local, which can be spelled thread_local if the correct header (<thread.h>) is included.

An alternative approach to "doing the dance" is proposed here. It is not intended that necessarily every occurence of _[UpperCaseChar]name need be replaced by this mechanism. It simply is intended to increase our arsenal of methods when we need to introduce such new keywords etc.

POSIX suffered from a similar problem, and in about 1995 or 1996 adopted the approach of reserving the namespace:

The prefixes posix_, POSIX_, and _POSIX_ are reserved for use by IEEE Std 1003.1-2001 and other POSIX standards.

This proposal suggests a similar approach for C,

The prefixes stdc_, STDC_, and __STDC_ are reserved for future standardization.

This would permit (but not require) us to use the keyword stdc_thread_local for thread local storage, for example.

Indeed, the current standard already reserves STDC as a prefix for pragmas (6.11.8) and __STDC_ for macros (6.11.9). It is unclear why the committee stopped at pragmas and macros. A Google code search shows that very few applications would be affected by such a reservation, and where applications do "break" the rule, they do so where they are mapping something to the standard C way of doing it.

Proposed wording for C

Replace 6.11.8 and 6.11.9 in their entirety with the following:

6.11.8 Pragma directives
Pragmas whose first preprocessing token is STDC are reserved for future standardization.
6.11.9 Predefined macro names Macro names beginning with __STDC_ are reserved for future standardization.

6.11.x Reserved Names The prefixes stdc_, STDC_, and __STDC_ are reserved for future standardization.