7.4.5 Persistent Objects
The __persistent
qualifier can be used to indicate that variables should
not be cleared by the runtime startup code.
Use the native keywords discussed in the Differences section to look up information on the semantics of this qualifier.
Example
The following shows a variable qualified using __persistent
.
__persistent int serialNo;
Differences
When targeting PIC devices, the MPLAB XC8 compiler has allowed use of the
persistent
specifier to indicate that variables should not be
cleared at startup. When targeting AVR devices, this compiler has allowed the use of the
persistent
attribute with variables to indicate they were not to be
cleared.
The MPLAB XC16, XC-DSC and XC32 compilers have also used the persistent
attribute for this purpose.
Migration to the CCI
When building with the MPLAB XC8 compiler for PIC MCUs, change any occurrence of the
persistent
qualifier to __persistent
, for example,
from:
persistent char template[20];
to:
__persistent char template[20];
When building with MPLAB XC16, XC-DSC or XC32 compilers, or with the MPLAB XC8 compiler
for AVR MCUs, change any occurrence of the persistent
attribute to the
__persistent
specifier, for example, from:
int tblIdx __attribute__ ((persistent));
to
int __persistent tblIdx;
Caveats
None.