C11 anonymous structs via typedefs?

后端 未结 3 1291
甜味超标
甜味超标 2021-02-07 08:05

Anonymous structs have been added in the C11 standard, so

typedef struct { 
    struct {int a, b};
    int c; 
} abc_struct;

is valid and stand

3条回答
  •  逝去的感伤
    2021-02-07 08:36

    Well, I'm afraid I haven't bothered to get the finished standard yet, but here's what the final draft says:

    • An unnamed member whose type specifier is a structure specifier with no tag is called an anonymous structure; an unnamed member whose type specifier is a union specifier with no tag is called an anonymous union.

    I can only interpret the as that only struct {}; and union {}; can be an anonymous struct/union.

提交回复
热议问题