来自K&R的C编程语言:
字段成员(不需要声明器,因此可以不命名)具有int、unsigned或signed类型,并被解释为指定长度的整型对象(以位为单位);int字段是否被视为有符号的对象取决于实现。结构的非字段成员根据其类型在寻址边界对齐;因此,结构中可能有未命名的孔。
引号中的第二句是否意味着字段成员只能具有int、unsigned i
unsigned char v64 : 1;} valid;main.c:17:3: warning: type of bit-field‘v64’ is a GCC extension [-pedantic]
main.c:18:3: warning: type of bit-field ‘leg’ is a GCC extension
EXIT_SUCCESS;student.c:42:26: error: cannot take address of bit-fieldStudent[i].birthdate.year);student.c:42:61: error: cannot take address of bit-field^
student.c:42:98: error: cannot take address of bit-fie
n", MAX(x.a, x.b));}error: 'typeof' applied to a bit-fielderror: '__auto_type' used with a bit-field initializer
所以问题是:为什么GCC不允许将这些字段与位字段一起使用(我找不到关于它的任何文档),以及如何使一个