c - : mean in C? 是什么

标签 c struct qemu bit-fields

<分区>

在查看QEMU的源码包时,在exec.c文件中发现:

struct PhysPageEntry {
    /* How many bits skip to next level (in units of L2_SIZE). 0 for a leaf. */
    uint32_t skip : 6;
     /* index into phys_sections (!skip) or phys_map_nodes (skip) */
    uint32_t ptr : 26;
};

我想知道 : 运算符是什么意思。我在 C 的语法定义列表中找不到它。

最佳答案

这是一个用位字段声明的结构,结构成员称为位字段:A 位字段设置有一个结构声明,该声明标记每个字段并确定其宽度。上述定义导致 PhysPageEntry 包含一个 6 位字段和一个 26 位字段成员,即 skipptr分别。它的签名是

struct
{
      type [member_name] : width ;
};  

这里的宽度是位域中的位数。 宽度必须小于或等于指定类型的位宽

关于c - : mean in C? 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21764725/

相关文章:

c - undefined reference '_method'

c - 移动到函数中的下一个字符串并在主函数中打印它(c)

windows-7 - Windows 7 在 kvm 上安装时停在 "starting windows"

c++ - reinterpret_cast 结构到固定大小的数组

docker - linuxkit getty 陷入困境

qemu - 构建错误: qemu-arm: command not found

c - 关于malloc的问题

c++ - count 参数是否应该直接在可变参数函数中的省略号 (...) 之前声明?

c - 在 char * 上使用 printf 和 scanf

C:为什么可以按值传递(给函数)结构,而不是数组?