C11通过匿名的typedef结构? [英] C11 anonymous structs via typedefs?
问题描述
匿名结构已在C11标准被添加,因此
Anonymous structs have been added in the C11 standard, so
typedef struct {
struct {int a, b};
int c;
} abc_struct;
是啥标准。是不是也很到位完整结构声明来使用typedef在标准范围内?例如:
is valid and standard. Is it also within the standard to use a typedef in place of the full struct declaration? E.g.:
typedef struct {
int a, b;
} ab_struct;
typedef struct {
ab_struct;
int c;
} abc_struct;
GCC的文件说,这是一个计划9延伸,但随后在工作
我试过几个编译器(包括GCC ...)。我的标准本身的阅读,
我认为这是好的,但这是那种近距离阅读,很容易搞砸了。
The GCC documentation says that this is a Plan 9 extension, but then it works in the few compilers I've tried (including GCC...). By my reading of the standard itself, I think it's OK, but this is the sort of close reading that's easy to screw up.
推荐答案
这显然是要求由的gcc约瑟夫·迈尔斯
团队的问题到C委员会。和答案是否定的,它不是在C11有效
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.
在这里看到答案:
<一个href=\"http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1549.pdf\">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1549.pdf
和迈尔斯的评论:
本周的伦敦WG14会议同意禁止使用的typedef的声明匿名结构和联合的字段,如每N1549。
This week's London WG14 meeting agreed to disallow the use of typedefs in declaring anonymous structure and union fields, as per N1549.
源<一个href=\"http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01151.html\">http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01151.html
有人问在SC22WG15.12205看到的 5.28 SC22WG14.12205,匿名结构(N1425)的在<一个href=\"http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1490.pdf\">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1490.pdf
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
这篇关于C11通过匿名的typedef结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!