I have the following code:
typedef struct Y {int X;} X;
enum E {X};
which generates a error:
error: ‘X’ redeclared as different kind of symbol
As I know, C has implicitly defined namespaces for structure, union, and enum tags and also for their members. So, I’m not sure why does E::X collide with typedef structure tag X?
What exactly are name spaces in C?
C does not have a separate namespace for
enummembers. When you writeenum {X}, that creates a global constantX(which can clash with other global names such astypedef‘d tags).