CRC16 generation function - Error C195 illegal indirection

137 views Asked by At

I am trying to implement CRC16 function into my code. When I try to compile it gives me an error:C195 "illegal indirection" on Keil. Any guidance on the matter would be greatly appreciated!

         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...}
1

There are 1 answers

0
Mark Adler On BEST ANSWER

You need to put the declarations of the function arguments (puchMsg and usDataLen) after the function declaration (CRC16). Better yet would be to use modern C, where modern began 30 years ago, and put the parameter types in the function declaration:

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