#define dCPUWRITE_Rx1 (*(volatile struct tag_ID501 *)&vCPUWRITE_Rx1[0])
unsigned char vCPUWRITE_Rx1[8];
struct tag_ID501
{
unsigned char CPUWRITE_DAT1;
unsigned char CPUWRITE_DAT2;
unsigned char CPUWRITE_DAT3;
unsigned char CPUWRITE_DAT4;
unsigned char CPUWRITE_BYTE;
unsigned char CPUWRITE_ADDR1;
unsigned short CPUWRITE_ADDR2;
};
通过以上定义后,数组是不是这样引用的vCPUWRITE_Rx1[0].CPUWRITE_DAT1;vCPUWRITE_Rx1[0].CPUWRITE_DAT2...........vCPUWRITE_Rx1[0].CPUWRITE_ADDR2。但是数组是char型结构体第7个元素是short型,类型不对。
在项目里最高引用到vCPUWRITE_Rx1[5]高于5报错。语句:dat = &vCPUWRITE_Rx1[0];//dat是内部指针变量char型。
求详解。