我编译了这个(gcc 编译器):
#include <stdio.h>
main() {
struct {
a:1;
b:2;
} t;
t.b=6;
t.a=2;
printf("%d %d",t.a,t.b);
}
显示的错误是:
'a' 之前的预期说明符-限定符列表
为什么在未命名数据变量默认取int时需要它。请解释...
最佳答案
这是 C language standard 所要求的.根据 6.7.2.1 第 4 部分:
A bit-field shall have a type that is a qualified or unqualified version of _Bool, signed int, unsigned int, or some other implementation-defined type.
关于c - 为什么需要说明符限定符列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10056451/