#include <stdio.h>
typedef unsigned char BOOL_T;
typedef unsigned char U8_T;
typedef signed char S8_T;
typedef unsigned short U16_T;
typedef signed short S16_T;
typedef unsigned int U32_T;
typedef signed int S32_T;
typedef unsigned long long U64_T;
typedef long long S64_T;
typedef float F32_T;
typedef double F64_T;
typedef char * STR_T;
#define DATA_TYPE_U8 0
#define DATA_TYPE_U16 1
#define DATA_TYPE_U32 2
#define DATA_TYPE_F32 3
typedef struct
{
U8_T u8_value1;
U32_T u32_value2;
U8_T u8_value3;
U32_T u32_value4;
S32_T s32_value5;
U8_T u8_value6;
}REAL_T;
typedef struct
{
void *value;
U8_T type;
}INFO_T;
static REAL_T m_t_real1, m_t_real2;
static INFO_T m_t_info1[] =
{
{&m_t_real1.u8_value1, DATA_TYPE_U8},
{&m_t_real1.u32_value2, DATA_TYPE_U32},
{&m_t_real1.u8_value3, DATA_TYPE_U8},
{&m_t_real1.u32_value4, DATA_TYPE_U32},
{&m_t_real1.s32_value5, DATA_TYPE_U32},
{&m_t_real1.u8_value6, DATA_TYPE_U8},
};
static INFO_T m_t_info2[] =
{
{&m_t_real2.u8_value1, DATA_TYPE_U8},
{&m_t_real2.u32_value2, DATA_TYPE_U32},
{&m_t_real2.u8_value3, DATA_TYPE_U8},
{&m_t_real2.u32_value4, DATA_TYPE_U32},
{&m_t_real2.s32_value5, DATA_TYPE_U32},
{&m_t_real2.u8_value6, DATA_TYPE_U8},
};
typedef struct
{
INFO_T *t_info;
}PACKET_T;
static PACKET_T m_t_paket[]=
{
{m_t_info1},
{m_t_info2},
};
int main(int argc, char *argv[])
{
unsigned char i;
INFO_T *t_info;
m_t_real1.u8_value1 = 1;
m_t_real1.u32_value2 = 0x0AABBCCDD;
m_t_real1.u8_value3 = 0x02;
m_t_real1.u32_value4 = 0xFFFFAADD;
m_t_real1.s32_value5 = 123;
m_t_real1.u8_value6 = 11;
m_t_real2.u8_value1 = 4;
m_t_real2.u32_value2 = 0x0CCBBCCFF;
m_t_real2.u8_value3 = 0x02;
m_t_real2.u32_value4 = 0xAAFFAADD;
m_t_real2.s32_value5 = 333;
m_t_real2.u8_value6 = 123;
printf("**********m_t_info1***********\r\n");
for (i = 0; i < 6; i++)
{
if (m_t_info1[i].type == DATA_TYPE_U8)
printf("U8_T value = %x\n", *((U8_T*)(m_t_info1[i].value)));
else if (m_t_info2[i].type == DATA_TYPE_U32)
printf("U32_T value = %x \n", *((U32_T*)(m_t_info1[i].value)));
}
printf("**********m_t_info2***********\r\n");
for (i = 0; i < 6; i++)
{
if (m_t_info2[i].type == DATA_TYPE_U8)
printf("U8_T value = %x\n", *((U8_T*)(m_t_info2[i].value)));
else if (m_t_info2[i].type == DATA_TYPE_U32)
printf("U32_T value = %x \n", *((U32_T*)(m_t_info2[i].value)));
}
#if 1
printf("**********t_info1***********\r\n");
t_info = m_t_paket[0].t_info;
for (i = 0; i < 6; i++)
{
if (t_info[i].type == DATA_TYPE_U8)
printf("U8_T value = %x\n", *((U8_T*)(t_info[i].value)));
else if (t_info[i].type == DATA_TYPE_U32)
printf("U32_T value = %x \n", *((U32_T*)(t_info[i].value)));
}
#endif
printf("**********t_info2************\r\n");
t_info = m_t_paket[1].t_info;
for (i = 0; i < 6; i++)
{
if (t_info[i].type == DATA_TYPE_U8)
printf("U8_T value = %x\n", *((U8_T*)(t_info[i].value)));
else if (t_info[i].type == DATA_TYPE_U32)
printf("U32_T value = %x \n", *((U32_T*)(t_info[i].value)));
}
return 0;
}
01-31
2万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)