While reading I came across this type of declaration and the following line -
const volatile char *p=(const volatile char *) 0x30;
const
doesn't make a variable constant. It just make the compiler refuse some write access. This is still possible to write in the variable (via const-casted pointers for instance).
You can see const
as a protection against coding mistakes.
This declaration make sure you don't inadvertently write to p
, while telling the compiler not to optimize accesses (cache, out of order execution(?),...) because an external event may write in p
.