[英]Is a bit-field an object?
According to C11, an object is: 根据C11,一个目标是:
#C11 § 3: Terms, definitions, and symbols
#C11§3:术语,定义和符号
object : region of data storage in the execution environment, the contents of which can represent values.object :执行环境中的数据存储区域,其内容可以表示值。
A bitfield can represent a value, so it should be an object. 位域可以表示一个值,因此它应该是一个对象。 But, I have been told it was not the case.
但是,我被告知事实并非如此。
What is the correct answer? 什么是正确的答案?
6.2.6.1p2 says " Except for bit-fields, objects are composed of contiguous sequences of one or more bytes [...] ", so it seems clear that bit-fields are objects. 6.2.6.1p2说“ 除了位字段,对象由一个或多个字节的连续序列组成[...] ”,因此很明显位字段是对象。 Similarly, 6.2.6.1p4 refers to " non-bit-field objects ".
类似地,6.2.6.1p4指的是“ 非位域对象 ”。
3.5p1 defines the bit as the unit of data storage; 3.5p1将该位定义为数据存储单元; a bit field is a region of bits so must be a region of data storage.
位字段是位区域,因此必须是数据存储区域。 The standard distinguishes between objects and memory locations (a memory location is " either an object of scalar type, or a maximal sequence of adjacent bit-fields all having nonzero width "; 3.14p1) so an object need not have a distinct memory location.
该标准区分对象和存储器位置(存储器位置是“ 标量类型的对象,或者所有具有非零宽度的相邻位域的最大序列 ”; 3.14p1)因此对象不需要具有不同的存储器位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.