我有以下结构。当我使用sizeof(ipj_tag_operation_report)打印结构的大小时,我得到值480.但是当我尝试添加此结构中包含的每种数据类型的单个大小时,我只得到405.此外,如果我添加大小数据类型," rssi"字段值以第165个字节出现。但是当我在JNA中获得这个结构时,当我遍历返回的内容时,它位于数组的第51个位置。为什么这些不匹配?我在这做错了什么?请指教。
以下是我的结构及其相关结构。我已经评论了数据类型的大小。这些是我在互联网上找到的价值观。
typedef struct
{
bool has_error; //1
ipj_error error; //4
bool has_tag; //1
ipj_tag tag; //174
bool has_tag_operation_type; //1
ipj_tag_operation_type tag_operation_type; //4
bool has_tag_operation_data; //1
ipj_tag_operation_data_t tag_operation_data; //72
bool has_retries; //1
uint32_t retries; //4
bool has_diagnostic; //1
uint32_t diagnostic; //4
bool has_timestamp; //1
uint64_t timestamp; //8
size_t lt_buffer_count; //8
uint32_t lt_buffer[30]; //120
} ipj_tag_operation_report;
typedef uint32_t ipj_error;
typedef struct
{
bool has_epc; //1
ipj_epc_t epc; //72
bool has_tid; //1
ipj_tid_t tid; //56
bool has_pc; //1
uint32_t pc; //4
bool has_xpc; //1
uint32_t xpc; //4
bool has_crc; //1
uint32_t crc; //4
bool has_timestamp; //1
uint64_t timestamp; //8
bool has_rssi; //1
int32_t rssi; //4
bool has_phase; //1
int32_t phase; //4
bool has_channel; //1
uint32_t channel; //4
bool has_antenna; //1
uint32_t antenna; //4
} ipj_tag;
typedef uint32_t ipj_tag_operation_type;
typedef struct
{
size_t size;
uint8_t bytes[64];
} ipj_tag_operation_data_t;
typedef unsigned __int64 size_t;