MbedCRC.h: declare table specialisations

Clang emits warnings if it can see a declaration when it needs a
templated variable. Add declarations for the specialisations in
MbedCRC.cpp to MbedCRC.h keep it quiet.

Tighten up a little by making all `_crc_table` references conditional
on tables being configured on.
pull/11897/head
Kevin Bracey 2019-11-19 14:16:23 +02:00
parent b77f6b457e
commit 04f929e85f
1 changed files with 28 additions and 5 deletions

View File

@ -479,11 +479,10 @@ private:
>>;
// *INDENT-ON*
/* Not [MBED_CRC_TABLE_SIZE] as that could be [0], which is illegal.
* We do need the declaration to always exist so that do_compute_partial<TABLE> is always well-formed,
* but we never actually use it MBED_CRC_TABLE_SIZE is 0.
*/
static const crc_table_t _crc_table[];
#if MBED_CRC_TABLE_SIZE > 0
/* Tables only actually defined for mode == TABLE, and certain polynomials - see below */
static const crc_table_t _crc_table[MBED_CRC_TABLE_SIZE];
#endif
static uint32_t adjust_initial_value(uint32_t initial_xor, bool reflect_data)
{
@ -742,6 +741,7 @@ private:
return 0;
}
#if MBED_CRC_TABLE_SIZE > 0
/** CRC computation using ROM tables.
*
* @param buffer data buffer
@ -774,6 +774,7 @@ private:
*crc = p_crc;
return 0;
}
#endif
#ifdef DEVICE_CRC
/** Hardware CRC computation.
@ -793,6 +794,28 @@ private:
};
#if MBED_CRC_TABLE_SIZE > 0
/* Declarations of the tables we provide. (Not strictly needed, but compilers
* can warn if they see us using the template without a generic definition, so
* let it know we have provided these specialisations.)
*/
template<>
const uint8_t MbedCRC<POLY_7BIT_SD, 7, CrcMode::TABLE>::_crc_table[MBED_CRC_TABLE_SIZE];
template<>
const uint8_t MbedCRC<POLY_8BIT_CCITT, 8, CrcMode::TABLE>::_crc_table[MBED_CRC_TABLE_SIZE];
template<>
const uint16_t MbedCRC<POLY_16BIT_CCITT, 16, CrcMode::TABLE>::_crc_table[MBED_CRC_TABLE_SIZE];
template<>
const uint16_t MbedCRC<POLY_16BIT_IBM, 16, CrcMode::TABLE>::_crc_table[MBED_CRC_TABLE_SIZE];
template<>
const uint32_t MbedCRC<POLY_32BIT_ANSI, 32, CrcMode::TABLE>::_crc_table[MBED_CRC_TABLE_SIZE];
#endif // MBED_CRC_TABLE_SIZE > 0
} // namespace impl
#endif // !defined(DOXYGEN_ONLY)