Double const declaration

It's a constant pointer to a constant unsigned char. You can't change the pointer nor the thing it points to.


type declarations should(?) be read RTL. const modifies the thing on its left, but the rule is complicated by the fact that you can write both const T and T const (they mean the same thing).

  • T * const is a constant pointer to mutable T
  • T & const would be constant reference to mutable T, except references are constant by definition
  • T const * is a mutable pointer to constant T
  • T const & is a reference to constant T
  • T const * const is constant pointer to constant T

The first const says that the data pointed to is constant and may not be changed whereas the second const says that the pointer itself may not be changed:

char my_char = 'z';
const char* a = &my_char;
char* const b = &my_char;
const char* const c = &my_char;

a = &other_char; //fine
*a = 'c'; //error
b = &other_char; //error
*b = 'c'; //fine
c = &other_char; //error
*c = 'c'; //error