3.23 __ro_placement Keyword
The IAR __ro_placement
keyword specifies that the qualified const
volatile
objects should be placed in read-only memory.
Suggested Replacement
This keyword can be removed when using a memory-placement feature of MPLAB XC8, or alternatively, there are MPLAB XC8 qualifiers that perform a similar task to this keyword.
When enabled (the default state), the MPLAB XC8's const-data-in-program-memory
feature places const volatile
objects into program memory. In this
case, the IAR keyword is redundant and should be removed.
When this feature is disabled, using the -mno-const-data-in-progmem
option, use both the const
and __memx
qualifiers
to have these objects placed in program memory.
Caveats
If the const-in-program-memory feature is disabled, alternate versions of the string
functions normally provided by <string.h>
must be used to
access string objects located in program memory.
Examples
volatile const int __ro_placement myVar = 2;
volatile int x;
int main(void) {
x = myVar;
}
to
MPLAB XC8 code similar
to:volatile const int myVar = 2;
volatile int x;
int main(void) {
x = myVar;
}
when
building with the const-data-in-program-memory feature enabled.Further Information
See the Options Specific to AVR Devices section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on the const-data-in-program-memory feature.