Identifier Length/limit in C++....??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rohit1937
    New Member
    • Jul 2014
    • 1

    Identifier Length/limit in C++....??

    I just want to know what is the length of Identifiers in C++. In C its length is 32 but I don't know what is the length in C++...
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    There is no mandatory maximum limit but the C++ Standard says a length of 1024 should be supported.

    I saw one implementation where the identifier length was quite long but required to be unique in the first 32 positions.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      The C Standard sets the minimum number of significant characters that must be supported by all conforming implementations . Some implementations exceed these minimums, but taking advantage of that benefit can make your software hard to port to other implementations .

      C89 Standard:
      6 characters for external identifiers;
      31 characters for internal identifiers.

      C99 Standard:
      31 characters for external identifiers;
      63 characters for internal identifiers.

      C11 Standard:
      (same as C99)
      31 characters for external identifiers;
      63 characters for internal identifiers.

      The limit on external identifiers is relevant for conforming linkers.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Also keep in mind that C++ uses name mangling (decoration)so the actual identifier used by the compiler is not the one you coded. The algorithm is compiler specific so different compilers will use different mangled names for your identifier.

        A rose is a @&r!!os@)e. :)

        Comment

        Working...