Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • No other variable should share the name of a global variable if the other value is in a subscope of the global variable.
  • A block should not declare a variable with the same name as a variable declared in any block that contains it.

...

Code Block
bgColor#FFCCCC
char msg[100];

void hello_message()
 {
  char msg[80] = "Hello";
  strcpy(msg, "Error");
}

...

Code Block
bgColor#ccccff
char error_msg[100];

void hello_message()
 {
  char hello_msg[80] = "Hello";
  strcpy(error_msg, "Error");
}

...

When the block is small, the danger of reusing variable names is mitigated by the visibility of the immediate declaration. Even in this case, however, variable name reuse is not desirable.

...