From 4a15c91ddad3e4d640cf7ff2e68b42fa87adb4ce Mon Sep 17 00:00:00 2001 From: coffee Date: Mon, 17 Mar 2025 22:00:00 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/HBit.h | 4 +--- include/HByteStack.h | 10 ++++------ include/HVector.h | 10 ++++------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/include/HBit.h b/include/HBit.h index 7d16f3f..95ed953 100644 --- a/include/HBit.h +++ b/include/HBit.h @@ -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)) diff --git a/include/HByteStack.h b/include/HByteStack.h index e1b896b..2353903 100644 --- a/include/HByteStack.h +++ b/include/HByteStack.h @@ -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) diff --git a/include/HVector.h b/include/HVector.h index 332e02a..9d3adb9 100644 --- a/include/HVector.h +++ b/include/HVector.h @@ -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))