The C language allows anonymous struct and enum definitions in type definitions. Using such definitions prevents the compiler from properly applying program-level interprocedural analysis. Make sure to give names to structures and enumerations in type definitions. Listing: Unnamed structures and enumerations in C shows an example of unnamed structures and enumerations and Listing: Naming structures and enumerations in C shows a suggested solution.
/* In C, the types x_rec and y_enum each represent a structure and an enumeration with no name. In C++ these same statements define a type x_rec and y_enum, a structure named x_rec and an enumeration named y_enum. */ typedef struct { int a, b, c; } x_rec; typedef enum { Y_FIRST, Y_SECOND, Y_THIRD } y_enum;
typedef struct x_rec { int a, b, c; } x_rec; typedef enum y_enum { Y_FIRST, Y_SECOND, Y_THIRD } y_enum;