Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Wiki MarkupThe C+\+ Standard \ [[ISO/IEC 14882-2003|AA. Bibliography#ISO/IEC 14882-2003]\], Section 17.4.3.1.2 specifies the following sets of reserved names:

  • Each name that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use.
  • Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
  • Each name declared as an object with external linkage in a header is reserved to the implementation to designate that library object with external linkage, both in namespace std and in the global namespace.
  • Each global function signature declared with external linkage in a header is reserved to the implementation to designate that function signature with external linkage.
  • Each name from the Standard C library declared with external linkage is reserved to the implementation for use as a name with extern "C" linkage, both in namespace std and in the global namespace.
  • Each function signature from the Standard C library declared with external linkage is reserved to the implementation for use as a function signature with both extern "C" and extern "C++" linkage, or as a name of namespace scope in the global namespace.
  • For each type T from the Standard C library, the types ::T and std::T are reserved to the implementation and, when defined, ::T shall be identical to std::T.
  • A translation unit that includes a standard library header shall not #define or #undef names declared in any standard library header.

Wiki MarkupIn addition, the C99 Standard \ [[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\], largely subsumed by C\+\+, specifies in section 7.1.3 the following sets of reserved names:

  • All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.
  • 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.
  • Each macro name in any of the subclauses (including the future library directions) is reserved for use as specified if any of its associated headers is included, unless explicitly stated otherwise.
  • All identifiers with external linkage(including future library directions) are always reserved for use as identifiers with external linkage.
  • Each identifier with file scope listed in any of the above subclauses (including the future library directions) is reserved for use as a macro name and as an identifier with file scope in the same name space if any of its associated headers is included.

No other identifiers are reserved #1. The behavior of a program that declares or defines an identifier in a context in which it is reserved or defines a reserved identifier as a macro name, is undefined . Trying to define a reserved identifier can result in its name conflicting with that used in implementation, which may or may not be detected at compile time.

Anchor
1
1
[1] Note that the POSIX ® standard extends the set of identifiers reserved by C99 to include an open-ended set of its own. See section 2.2 Compilation Environment in [IEEE Std 1003.1-2008]. Wiki Markup<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:macro-id="0599d0f5-3d39-4ddd-b144-866440de3fe0"><ac:parameter ac:name="">1</ac:parameter></ac:structured-macro> \[1\] Note that the POSIX ^&#xAE;^ standard extends the set of identifiers reserved by C99 to include an open-ended set of its own. See section [2.2 Compilation Environment|http://www.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02] in [\[IEEE Std 1003.1-2008\]|AA. References#IEEE Std 1003.1-2008].

Noncompliant Code Example (Header Guard)

...

This rule appears in the C Secure Coding Standard as DCL37-C. Do not declare or define a reserved identifier.

Bibliography

...

\[[ISO/IEC 14882-2003|AA. Bibliography#ISO/IEC 14882-2003]\] Section 17.4.3.1.2, "Global names" \
[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999] \] Section 7.1.3, "Reserved Identifiers"
[\[IEEE Std 1003.1-2008\]|AA. References#IEEE Std 1003.1-2008] Section 2.2 "The Compilation Environment"

...

DCL31-CPP. Do not define variadic functions      02. Declarations and Initialization (DCL)      DCL33-CPP. Never qualify a variable of reference type with const or volatile