1. 修改对齐方式

This commit is contained in:
coffee 2025-03-17 22:00:00 +08:00
parent ec1531f32a
commit 4a15c91dda
3 changed files with 9 additions and 15 deletions

View File

@ -35,13 +35,11 @@ enum eHBitFlag {
kHBitInitFlag = 0x80,
};
#pragma pack(1)
typedef struct _HBitBase {
typedef struct __attribute__ ((__packed__)) _HBitBase {
uint8_t flag;
HBitLenType len;
uint8_t data[0];
} _HBitBase;
#pragma pack()
#define _HBIT_CALC_LEN(num) (sizeof(_HBitBase) + (((num) + 7) / 8))

View File

@ -41,28 +41,26 @@ enum eHByteStackFlag {
kHByteStackNeedInit = 0x80, // 需要初始化
};
#pragma pack(1)
typedef struct _HByteStackBase {
typedef struct __attribute__ ((__packed__)) _HByteStackBase {
uint8_t flag;
HByteLenType len;
HByteLenType useLen;
} _HByteStackBase;
typedef struct _HByteStack8 {
typedef struct __attribute__ ((__packed__)) _HByteStack8 {
_HByteStackBase base;
uint8_t data[];
} _HByteStack8;
typedef struct _HByteStack16 {
typedef struct __attribute__ ((__packed__)) _HByteStack16 {
_HByteStackBase base;
uint16_t data[];
} _HByteStack16;
typedef struct _HByteStack32 {
typedef struct __attribute__ ((__packed__)) _HByteStack32 {
_HByteStackBase base;
uint32_t data[];
} _HByteStack32;
#pragma pack()
// 用于支持多数据类型的宏
#define _HBYTE_STACK_CALC_LEN8(num) (sizeof(_HByteStack8) + num)

View File

@ -39,29 +39,27 @@ typedef uint16_t HVectorLenType;
typedef uint8_t HVectorLenType; // vector长度类型
#endif
#pragma pack(1)
typedef struct _HVectorBase {
typedef struct __attribute__ ((__packed__)) _HVectorBase {
uint8_t flag;
HVectorLenType len;
HVectorLenType useLen;
} _HVectorBase;
typedef struct _HVector8 {
typedef struct __attribute__ ((__packed__)) _HVector8 {
_HVectorBase base;
uint8_t data[0];
} _HVector8;
typedef struct _HVector16 {
typedef struct __attribute__ ((__packed__)) _HVector16 {
_HVectorBase base;
uint16_t data[0];
} _HVector16;
typedef struct _HVector32 {
typedef struct __attribute__ ((__packed__)) _HVector32 {
_HVectorBase base;
uint32_t data[0];
} _HVector32;
#pragma pack()
// 用于支持多数据类型的宏
#define _HVECTOR_CALC_LEN8(len) (sizeof(_HVector8) + (len))