C11 anonymous structs via typedefs?

后端 未结 3 1290
甜味超标
甜味超标 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:28

    This was apparently asked in a question to the C committee by Joseph S. Myers of the gcc team. And the answer is no, it is not valid in C11.

    See the answer here:

    http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1549.pdf

    And Myers's comment:

    This week's London WG14 meeting agreed to disallow the use of typedefs in declaring anonymous structure and union fields, as per N1549.

    source http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01151.html

    The question was asked in SC22WG15.12205 see 5.28 SC22WG14.12205, Anonymous Structures (N1425) in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1490.pdf

提交回复
热议问题