编译器错误信息:没有使用未使用的类型名模板调用 FUNCTION(TYPES ARGS) 的匹配函数

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

这段代码有问题,编译器信息帮不上什么忙。

我有一个结构,我在结构中定义了一个无符号整数数组:

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

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

还有一个函数 Faster_CRC16 如下所示:

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;
};

在 Arduino 和 VisualStudio2019(编译器 MSVC)上编译时,都 returns 错误消息:

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

这是一个奇怪的信息,因为 uint8_t values[8]; 应该等同于 uint8_t* values;,因为两者都代表一个包含指向地址的指针的变量。

经过调查,发现问题与位于顶部的模板 header 有关!

template <typename any_type> //guilty piece of code

即使不使用,这些也会引起麻烦。这是一个非常愚蠢的 inattention/lazyness 错误,但至少知道它可能发生对你来说可能是有价值的。