According to the C Standard (6.2.3 Name spaces of identifiers)
1 If more than one declaration of a particular identifier is visible
at any point in a translation unit, the syntactic context
disambiguates uses that refer to different entities. Thus, there are
separate name spaces for various categories of identifiers, as
follows:
— label names (disambiguated by the syntax of the label declaration
and use);
— the tags of structures, unions, and enumerations (disambiguated by
following any32) of the keywords struct, union, or enum);
— the members of structures or unions; each structure or union has a
separate name space for its members (disambiguated by the type of the
expression used to access the member via the . or -> operator);
— all other identifiers, called ordinary identifiers (declared in
ordinary declarators or as enumeration constants).
This is
struct Tag
{
type Tag;
<and so on..>
};
a structure declaration with the name Tag
and at the same time it is a structure definition because it not only introduces the type struct Tag
but also declares its members.
You may at first declare a structure and then define it. For example
#include <stdio.h>
struct Tag;
struct Tag
{
int Tag;
};
int main(void)
{
struct Tag Tag = { .Tag = 10 };
printf( "Tag.Tag = %d\n", Tag.Tag );
return 0;
}
The program output is
Tag.Tag = 10
In this declaration
struct Tag
{
type Tag;
<and so on..>
} Tag;
there is declared an object of the type struct Tag
with the identifier Tag
. The structure has a data member with name Tag
. Thus there are declared two entities: a type struct Tag
and an object with the name Tag
of the structure type.
In this declaration
struct
{
type Tag;
<and so on..>
} Tag;
there is declared an object of unnamed structure type with the identifier Tag
. The problem with this declaration is that you can not refer to the type of the object.
You can meet one more declaration like
typedef struct Tag
{
type Tag;
<and so on..>
} Tag;
In this typedef declaration the identifier Tag
serves as an alias of the type struct Tag
.
Or
typedef struct
{
type Tag;
<and so on..>
} Tag;
In this typedef declaration the identifier Tag
serves as an alias of the unnamed structure type.
The C 2011 allows to declare anonymous structures.
From the C Standard (6.7.2.1 Structure and union specifiers)
13 An unnamed member of structure type with no tag is called an
anonymous structure; an unnamed member of union type with no tag is
called an anonymous union. The members of an anonymous structure or
union are considered to be members of the containing structure or
union. This applies recursively if the containing structure or union
is also anonymous.