4.12 default_variable_attributes Pragma
The IAR default_variable_attributes
pragma sets default segment placement, type
attributes, and object attributes for static storage duration object declarations and
definitions that do not otherwise specify type or object attributes or location.
Suggested Replacement
There is no equivalent MPLAB XC8 pragma. Some of this pragma's functionality can be achieved with a typedef or attribute.
The typedef
storage-class specifier can be used to associate
qualifiers, like __memx
, with a type that can be used with the
objects.
The MPLAB XC8 section
attribute can additionally be used with
objects to specify the section in which it is placed. If the Common C Interface is
enabled, you can instead use the __section
specifier.
Caveats
The sections generated by this attribute are not concatenated across translation
units by the linker, and the
-Wl,--section-start,section_name=address
option, which can place a section in memory, only works with custom (non-standard)
sections.
Examples
#pragma default_function_attributes = @ "MYSEG" __farflash
const int startP = 20;
#pragma default_function_attributes =
to
MPLAB XC8 code similar
to:#include <xc.h>
typedef const volatile __memx int cm_t;
cm_t startP __section("MYSEG") = 20;
and
build with the -mext=cci
option.Further Information
See the Attributes and Ext Option section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on this attribute.