This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

static Look-up-table

Can anybody suggest the best technique to use for storing a look-up table array in ROM? Right now I just have:
unsigned char code LUT1[256] = { 0, 1, 2, ..., 255};

Parents
  • "I'd also suggest declaring the "unsigned char" as const. You won't be able to change the table contents. So, let the compiler know that fact, and it (and lint) can then help you find any potential mistakes in using the table as though it were variable."

    Actually, there's no need, the 'code' specifier has the desired effect (unmodifiable lvalue).

    Given 'C''s notion of the meaning of const it may possibly be safer to rely on the 'code' specifier.

Reply
  • "I'd also suggest declaring the "unsigned char" as const. You won't be able to change the table contents. So, let the compiler know that fact, and it (and lint) can then help you find any potential mistakes in using the table as though it were variable."

    Actually, there's no need, the 'code' specifier has the desired effect (unmodifiable lvalue).

    Given 'C''s notion of the meaning of const it may possibly be safer to rely on the 'code' specifier.

Children
No data