66. constexpr-i

Question.5

A developer generates a CRC lookup table at compile time:

struct CRCTable { uint8_t data[256]; };

constexpr CRCTable generate_crc() {
   CRCTable t = {};
   for (int i = 0; i < 256; i++) {
       uint8_t crc = i;
       for (int j = 0; j < 8; j++)
            crc = (crc & 1) ? (crc >> 1) ^ 0x8C : crc >> 1;
       t.data[i] = crc;
   }
   return t;
}

static constexpr CRCTable crc_table = generate_crc();

Where is the 256-byte table stored in the final firmware binary?

Need Help? Refer to the Quick Guide below

Select Answer