Why use different a different tag and typedef for a struct?

后端 未结 5 508
离开以前
离开以前 2020-12-09 20:11

In C code, I\'ve seen the following:

typedef struct SomeStructTag {
    // struct members
} SomeStruct;

I\'m not clear on why this is any d

5条回答
  •  抹茶落季
    2020-12-09 20:51

    The point is that SomeStruct will then be a proper type name. So you don't have to type

    struct SomeStructTag my_struct;
    

    In declarations:

    SomeStruct my_struct;
    

    Other than that, IMHO the _t appended to a name stands for type, not tag.

提交回复
热议问题