CRC16 生成函数 - 错误 C195 非法间接寻址

CRC16 generation function - Error C195 illegal indirection

我正在尝试在我的代码中实现 CRC16 函数。当我尝试编译时,它在 Keil 上给我一个 error:C195“非法间接寻址”。任何关于此事的指导将不胜感激!

         unsigned char *puchMsg ;   /* message to calculate CRC upon */
         unsigned short usDataLen ; /* quantity of bytes in message */              
         unsigned short CRC16 ( puchMsg, usDataLen) 
            {
             unsigned char uchCRCHi = 0xFF ; /* high byte of CRC initialized */
         unsigned char uchCRCLo = 0xFF ;    /* low byte of CRC initialized */   
                                    
            unsigned uIndex ; /* will index into CRC lookup table */
        while (usDataLen--)                 /* pass through message buffer */
         {
                uIndex=uchCRCLo^*puchMsg++;         /* Calculate the CRC */
                uchCRCLo = uchCRCHi^auchCRCHi[uIndex];
                uchCRCHi = auchCRCLo[uIndex];
       }
            return (uchCRCHi<<8|uchCRCLo);
        }

/* One array contains all of the 256 possible CRC values for the
high byte of the 16–bit CRC field, and the other array contains all of the values for the low byte.*/

//* Table of CRC values for low–order byte */ 
const char auchCRCLo[] = {0x00, 0xC0,.....} 

///* Table of CRC values for high–order byte */
 const unsigned char auchCRCHi[] = {0x00, 0xC1...}

您需要将函数参数声明(puchMsgusDataLen放在函数声明(CRC16 之后。更好的方法是使用现代 C,现代 C 始于 30 年前,并将参数类型放在函数声明中:

unsigned short CRC16 (unsigned char *puchMsg, unsigned short usDataLen) {
...