更新时间:2023-02-01 19:00:16
您可以使用位字段,这些位字段通常用于表示已知的固定位宽的整数类型.位域的一种众所周知的用法是表示一组位和/或一系列位,称为标志.您可以对其应用位操作.
You can use the bit fields which are often used to represent integral types of known, fixed bit-width. A well-known usage of bit-fields is to represent a set of bits, and/or series of bits, known as flags. You can apply bit operations on them.
#include <stdio.h>
#include <stdint.h>
struct uint48 {
uint64_t x:48;
} __attribute__((packed));