Example:
int x[99];
void f() {
struct x { int a; };
sizeof(x);
}
Rationale: This is one of the few incompatibilities between C and C++ that
can be attributed to the new C++ name space definition where a
name can be declared as a type and as a non-type in a single scope
causing the non-type name to hide the type name and requiring that
the keywords
class,
struct,
union or
enum be used to refer to the type name
. This new name space definition provides important notational
conveniences to C++ programmers and helps making the use of the
user-defined types as similar as possible to the use of fundamental
types
. The advantages of the new name space definition were judged to
outweigh by far the incompatibility with C described above
. Effect on original feature: Change to semantics of well-defined feature
. Difficulty of converting: Semantic transformation
. If the hidden name that needs to be accessed is at global scope,
the
:: C++ operator can be used
. If the hidden name is at block scope, either the type or the struct
tag has to be renamed
.