This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

variable name confusion

void tst()
{
  { char  x; _x = 0; } // ... error C202: '_x': undefined identifier
  { char _x;  x = 0; } // No errors! Are "_x" and "x" the same here?
}

Parents
  • Drew Davis wrote:
    Identifiers that begin with an underscore are reserved for the language or implementation and shouldn't be used...
    This is correct

    Actually, it's not. Identifiers with a leading underscore are reserved only if either

    a) the second character is also an underscore,
    b) the second character is upper-case, or
    c) the name is at file-scope.

    Neither of the above applies to the case at hand, a block-scoped variable with a lower-case second character.

Reply
  • Drew Davis wrote:
    Identifiers that begin with an underscore are reserved for the language or implementation and shouldn't be used...
    This is correct

    Actually, it's not. Identifiers with a leading underscore are reserved only if either

    a) the second character is also an underscore,
    b) the second character is upper-case, or
    c) the name is at file-scope.

    Neither of the above applies to the case at hand, a block-scoped variable with a lower-case second character.

Children
No data