G
Grumble
Hello,
I thought names of enums and names of structs lived in different
namespaces, in C89. Am I mistaken? It would seem so:
$ cat testcase.c
struct foobar { int x,y,z; };
enum foobar {AAA, BBB, CCC};
int main(void) { return 0; }
$ gcc-3.4.3 -Wall -ansi -pedantic testcase.c
testcase.c:2: error: `foobar' defined as wrong kind of tag
$ icc-8.0 -strict_ansi testcase.c
testcase.c(2): error: "foobar" has already been declared in the current
scope
enum foobar {AAA, BBB, CCC};
^
compilation aborted for testcase.c (code 2)
It seems the correct term is 'scope' instead of 'namespace'? I don't
understand why the standard would impose such a limitation? It seems
trivial to determine that 'struct foobar' and 'enum foobar' are two
unrelated types?
I thought names of enums and names of structs lived in different
namespaces, in C89. Am I mistaken? It would seem so:
$ cat testcase.c
struct foobar { int x,y,z; };
enum foobar {AAA, BBB, CCC};
int main(void) { return 0; }
$ gcc-3.4.3 -Wall -ansi -pedantic testcase.c
testcase.c:2: error: `foobar' defined as wrong kind of tag
$ icc-8.0 -strict_ansi testcase.c
testcase.c(2): error: "foobar" has already been declared in the current
scope
enum foobar {AAA, BBB, CCC};
^
compilation aborted for testcase.c (code 2)
It seems the correct term is 'scope' instead of 'namespace'? I don't
understand why the standard would impose such a limitation? It seems
trivial to determine that 'struct foobar' and 'enum foobar' are two
unrelated types?