为什么CFBit被定义为UInt32?(Why is CFBit defined as a UInt32?)

编程入门 行业动态 更新时间:2024-10-28 11:27:39
为什么CFBit被定义为UInt32?(Why is CFBit defined as a UInt32?)

Apple将CFBit记录为UInt32,但我对此感到困惑。 如果每个用32 定义,那么这是否会破坏使用向量的目的? 我错过了什么吗?

Apple documents CFBit as being a UInt32, but I'm confused as to why. Doesn't that defeat the purpose of using a bit vector if each bit is defined with 32 bits? Am I missing something?

最满意答案

不,它不是,因为CFBit不是例如CFBitVector的存储类。 它仅用于比较位向量中特定位置的特定位是0还是1.编译器(clang)中没有内置类型来存储单个位(就像在嵌入式系统的某些编译器中一样),因此需要这种解决方法。 为什么选择UInt32才是出于这个目的,我无法分辨。

同样:CFBitVector内部不是 CFBit实例的向量。

No, it isn't, because CFBit is not the storage-class of e.g. a CFBitVector. It's just used to compare whether a particular bit at a specific position in a bitvector is 0 or 1. There is not built-in type in the compiler (clang) to store individual bits (like it is in some compilers for embedded systems), therefore such kind of workaround is needed. Why exactly UInt32 is choosen for that purpose, I can't tell.

Again: CFBitVector internally is NOT a vector of CFBit instances.

更多推荐

本文发布于:2023-08-06 12:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1448840.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定义   CFBit   defined

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!