5.3.6.2 Pointer-target Qualifiers
The __rom
and __ram
pointer-target
qualifiers can be used if you would like the compiler to confirm that targets assigned to a
pointer are in a particular memory space.
These qualifiers can be used only when declaring or defining pointers.
They cannot be used with ordinary variables and they have no effect on the placement of the
pointers themselves. These qualifiers are always enforced by the compiler and they are not
affected by the -maddrqual
option (see 4.6.1.1 Addrqual Option) or #pragma
addrqual
.
The assignment of an incompatible target to a pointer that uses one of these qualifiers will trigger an error, so in the following example:
const int __rom * in_ptr;
an error would be generated if your program assigned to
in_ptr
the address of an object that was in data memory. Use of
__rom
implies the const
qualifier, but it is
recommended that const
is explicitly used to ensure the meaning of your
code is clear.
The use of these qualifiers must be consistent across all declarations of a pointer and it is illegal to use both qualifiers with the same pointer variable.