I have just discovered that both gcc
and clang
accept the following code:
typedef int blah;
struct s { char blah; };
However, they reject this, since a type name is being used as an identifier:
typedef int blah;
char blah;
Does this mean that the typedef'd name is not visible inside the struct definition? No, because this works in both gcc and clang:
typedef int blah;
struct s { blah blah; }
I am looking in the C99 standard and can't find anything which clarifies why a typedef'd name can be used as the name of a struct member, but not of a variable in the same scope.
Can someone explain why this is? A reference to any applicable standard would be appreciated.