A.1.3 Defining const pointer

The pointer is interpreted differently depending on the "const" specified location.

-

const char *p;

This indicates that the object (*p) which pointer p points to cannot be rewritten.

The pointer itself (p) can be rewritten.

Therefore each statement in the following example is judged as written in the comment and the pointer itself is allocated to RAM (.data etc.).

*p = 0;     /*error*/
p = 0;      /*correct*/

-

char *const p;

This indicates that the pointer itself (p) cannot be rewritten.

The object (*p) which pointer p points to can be rewritten.

Therefore each statement in the following example is judged as written in the comment and the pointer itself is allocated to ROM (.const/.constf).

*p = 0;     /*correct*/
p = 0;      /*error*/

-

const char *const p;

This indicates that neither the pointer itself(p) and the object (*p) which pointer p points to can be rewritten.

Therefore each statement in the following example is judged as written in the comment and the pointer itself is allocated to ROM (.const/.constf)).

*p = 0;     /*error*/
p = 0;      /*error*/