Compiler error info : No matching function for call to FUNCTION(TYPES ARGS) with unused typename template

83 Views Asked by At

I have had an issue with this bit of code, and compiler info didn't help much.

I have a structure where I define an unsigned int array in a structure :

struct TypeHolder {
    uint8_t byte_size;
    uint8_t values[8]{ 0 };

    TypeHolder() {
        byte_size = 0;
    };
    
    uint16_t calcCRC() {
      return Faster_CRC16(values);
    };
};

And a function Faster_CRC16 which goes as follows :

template <typename any_type>
uint16_t Faster_CRC16(uint8_t* data_string_litteral){
  /* bunch of stuff */
    uint8_t b = data_string_litteral[j - 1]; // access an item of the array through indexation
  /* bunch of stuff */
  return crc_data;
};

When compiling this on Arduino and VisualStudio2019 (compiler MSVC), both returns error message :

no matching function for call to 'Faster_CRC16(uint8_t [8])'

It is a strange info, as uint8_t values[8]; is supposed to be equivalent to uint8_t* values; in the fact that both represent a variable holding a pointer to an address.

1

There are 1 best solutions below

0
On BEST ANSWER

After investigation, it turns out the issue was related to the template header that was sitting on top !

template <typename any_type> //guilty piece of code

Even unused, these can cause trouble. It is a realy stupid inattention/lazyness error, but at least knowing that it could happen may be valueable to you.