二维数组拷贝遇到不兼容指针类型传递,求解
程序代码:
typedef struct { uint8_t Key_Adc_Enable; const uint8_t *pAdc_Tab; uint16_t *pAdc_Val; uint8_t adc_TabNumber; uint8_t adc_ValNumber; } KEY_ADC_CFG_T; typedef struct { KEY_ADC_CFG_T *pstKEY_ADC_cfg; } KeySrv; typedef struct { KEY_ADC_CFG_T KEY_ADC_CFG_TO[2]; } DISPLAY_CFG_T; const uint8_t KeyAdcNum_tbl[] = { 1, //ADC1 2, //ADC2 }; #define KEY_ADC_NUM (sizeof(KeyAdcNum_tbl) / sizeof(KeyAdcNum_tbl[0])) uint16_t KeyAdc0Val_tbl[]= { 50, 150, 500, }; #define KEY_ADC0_VAL (sizeof(KeyAdc0Val_tbl) / sizeof(KeyAdc0Val_tbl[0])) uint16_t KeyAdc1Val_tbl[]= { 50, 150, 500, }; #define KEY_ADC1_VAL (sizeof(KeyAdc1Val_tbl) / sizeof(KeyAdc1Val_tbl[0])) static const DISPLAY_CFG_T gstDISPLAYConfig = { .KEY_ADC_CFG_TO[0] = { .Key_Adc_Enable = 1, .pAdc_Tab = KeyAdcNum_tbl, .pAdc_Val = KeyCusAdc0Val_tbl, .adc_TabNumber = KEY_ADC_NUM, .adc_ValNumber = KEY_ADC0_VAL, }, .KEY_ADC_CFG_TO[1] = { .Key_Adc_Enable = 1, .pAdc_Tab = KeyCusAdcNum_tbl, .pAdc_Val = KeyCusAdc1Val_tbl, .adc_TabNumber = KEY_ADC_NUM, .adc_ValNumber = KEY_ADC1_VAL, }, }; void printf_arrs(int index,int index2,uint16_t arr[index][index2]) { int i,j; for(i=0;i<index;i++) { for(j=0;j<index2;j++) printf("%d ",arr[i][j]); printf("\n"); } } void arrs_copy(int index,int index2,uint16_t arr[index][index2],uint16_t arr2[index][index2]) { int i,j; for(i=0;i<index;i++) { for(j=0;j<index2;j++) { arr[index-1][j]=arr2[i][j]; } } } int AdcKeyCode(KEY_ADC_CFG_T *AdcCfg, int *KeySrc) { int i = 0,j=0,res =0,flag = 0,ret = 0; (void) res;(void) flag;(void) ret; static uint16_t CurKeyVal[4] [4]; memset(CurKeyVal,0,sizeof(CurKeyVal)); for (i = 0; i < AdcCfg[i].adc_TabNumber; i++) { res = ADCScan(NULL, AdcCfg[i].pAdc_Tab[i]); // adc1 adc2 for (j = 0; j < AdcCfg[i].adc_TabNumber*AdcCfg[i].adc_ValNumber; j++) { if (j==AdcCfg[i].adc_TabNumber*AdcCfg[i].adc_ValNumber-1) { //ret = j; } else { //ret = j; } if (res < AdcCfg[i].pAdc_Val[j]) { int KeyTemp =0; flag = 1; ret = j; if (i == 0){ //是想把AdcCfg[i].pAdc_Val[j]二维数组的第一行拷贝到CurKeyVal第一行, //arrs_copy我在Dev c++验证过是可以的,但这里会报AdcCfg->pAdc_Val不兼容指针类型传递,需要怎么修改才能通过呢 arrs_copy(1, 3,CurKeyVal,AdcCfg->pAdc_Val); printf_arrs(3,3,CurKeyVal); } if (i == 1){ } KeyTemp = *KeySrc; break; } } } return (ret); } int KeyActive(KeySrv *const me, QEvt const *const e) { int iADC_Key = -1; ..... iADC_Key = CustomAdcKeyCode(me->pstKEY_CUS_ADC_cfg,&get_key_src); .... }