通过其地址在访问C位场 [英] Accessing bit-field in C by its address
问题描述
什么是背后不允许使用地址来访问在C位字段的原因,是它,因为它可能不是,是不是系统字对齐地址..?或者,因为它没有意义的一个字节中得到位地址......?(导致这种类型的指针运算会尴尬?)
What is the reason behind not allowing to access a bit field in C using its address, is it cause it might not be an address that is not system word aligned ..? or as it doesn't make sense to get bit's address within a byte...?(cause this types pointer arithmetic will be awkward ?)
推荐答案
位没有地址。这就是为什么你不能按地址引用它们。解决的粒度是字符
。
Bits do not have addresses. That's why you can't refer to them by address. The granularity of addressing is the char
.
我猜的理由是,语言是设计与之相匹配的目标架构,我知道没有机器它允许处理个人位的。
I guess the reasoning is that the language was design to match the architecture it targeted, and I know of no machine which allows addressing of individual bits.
这篇关于通过其地址在访问C位场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!