Thursday, 21 March 2024

Identifiers in c++

An identifier is a name that you define or that is defined in a library. An identifier begins with a nondigit character and is followed by any number of digits and nondigits. A nondigit character is a letter, an underscore, or one of a set of universal characters. The exact set of nondigit universal characters is defined in the C++ standard and in ISO/IEC PDTR 10176. Basically, this set contains the universal characters that represent letters. Most programmers restrict themselves to the characters a ... z , A ... Z , and underscore, but the standard permits letters in other languages.

Not all compilers support universal characters in identifiers.

Certain identifiers are reserved for use by the standard library :

  1. Any identifier that contains two consecutive underscores ( like__this ) is reserved, that is, you cannot use such an identifier for macros, class members, global objects, or anything else.
  2. Any identifier that starts with an underscore, followed by a capital letter (A–Z) is reserved.
  3. Any identifier that starts with an underscore is reserved in the global namespace. You can use such names in other contexts (i.e., class members and local names).
  4. The C standard reserves some identifiers for future use. These identifiers fall into two categories: function names and macro names. Function names are reserved and should not be used as global function or object names; you should also avoid using them as "C" linkage names in any namespace. Note that the C standard reserves these names regardless of which headers you #include . The reserved function names are :
    • is followed by a lowercase letter, such as isblank
    • mem followed by a lowercase letter, such as memxyz
    • str followed by a lowercase letter, such as strtof
    • to followed by a lowercase letter, such as toxyz
    • wcs followed by a lowercase letter, such as wcstof
    • In <cmath> with f or l appended, such as cosf and sinl
  5. Macro names are reserved in all contexts. Do not use any of the following reserved macro names:
    • Identifiers that start with E followed by a digit or an uppercase letter.
    • Identifiers that start with LC_ followed by an uppercase letter
    • Identifiers that start with SIG or SIG_ followed by an uppercase letter

 

Source : ISBN-10: 0-596-00298-X
              ISBN-13: 978-0-596-00298-5
              [M]

No comments:

Post a Comment