If I declare in a header file, for example, extern unsigned long * Ptr;
and the value of this pointer Ptr in the linker file.
Will this adrress be ‘constant’? Can I change its value ?
3
extern unsigned long *Ptr;
You can write to both Ptr
(point to a new object) and *Ptr
(update the thing being pointed to).
extern const unsigned long *Ptr;
extern unsigned long const *Ptr;
You can write to Ptr
(point to a new object), but you cannot write to *Ptr
.
extern unsigned long * const Ptr;
You can write to *Ptr
(update the thing being pointed to), but you cannot write to Ptr
.
extern const unsigned long * const Ptr;
extern unsigned long const * const Ptr;
You cannot write to either Ptr
or *Ptr
.
In all cases, the value of &Ptr
does not change.
Naturally, this assumes a matching defining declaration for Ptr
.