What are the differences between these two typedef styles in C?

后端 未结 6 1270
野趣味
野趣味 2021-01-11 14:24

I\'m curious what the difference here is when typedefing an enum or struct. Is there any difference semantically between these two blocks?

This:

typ         


        
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 14:38

    For structs there's a real difference that isn't simply about naming.

    This is valid C:

    struct SomeEnum { struct SomeEnum *first; };
    

    This is not:

    typedef struct { SomeEnum *first; } SomeEnum;
    

提交回复
热议问题