c++ - C 和 C++ 奇怪的语法 "unsigned int :32;"

标签 c++ c

<分区>

这行代码是什么意思:

    unsigned int                   :32       ;

它来自:

      typedef struct avr32_pwm_channel_t {
      union {
              unsigned long                  cmr       ;//0x0000
              avr32_pwm_cmr_t                CMR       ;
      };
              unsigned long                  cdty      ;//0x0004
              unsigned long                  cprd      ;//0x0008
        const unsigned long                  ccnt      ;//0x000c
              unsigned long                  cupd      ;//0x0010
              unsigned int                   :32       ;//0x0014
              unsigned int                   :32       ;//0x0018
              unsigned int                   :32       ;//0x001c
    } avr32_pwm_channel_t;

我尝试用谷歌搜索它,但什么也没找到

最佳答案

这叫做位域。它决定了结构中每个成员的宽度。

参见 https://en.wikipedia.org/wiki/Bit_field .

关于c++ - C 和 C++ 奇怪的语法 "unsigned int :32;",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36878225/

相关文章:

c++ - 如何在 C++ OpenCV 中将图像 (Mat) 转换为 inputArray?

c++ - 通过 CGI 生成 3D GUI

c++ - 使用 Boost ASIO 进行 Boost 异常处理

带括号和不带括号的 C++ 类初始化

c - 不输入 if 语句

C - 逐字节双线性缩放(插值)

c - 使用 Linux 内核中的循环缓冲区宏

c++ - 将类转换为结构

c - 指针明显无缘无故地改变 - C

c++ - else if 和大括号