Untagged Structures And Typedefs
Go Up to Structures Index
If you omit the structure tag, you can get an untagged structure. You can use untagged structures to declare the identifiers in the comma-delimited struct-id-list to be of the given structure type (or derived from it), but you cannot declare additional objects of this type elsewhere
struct { ... } s, *ps, arrs[10]; // untagged structure
It is possible to create a typedef while declaring a structure, with or without a tag:
typedef struct mystruct { ... } MYSTRUCT; MYSTRUCT s, *ps, arrs[10]; // same as struct mystruct s, etc. typedef struct { ... } YRSTRUCT; // no tag YRSTRUCT y, *yp, arry[20];
Usually, you don't need both a tag and a typedef: either can be used in structure declarations.
Untagged structure and union members are ignored during initialization.