SPRUIG8J January 2018 – March 2024
The following variable attributes are supported:
The aligned attribute used on a variable has the same effect as the DATA_ALIGN pragma. See Section 5.8.6
The location attribute has the same effect as the LOCATION pragma. See Section 5.8.22. For example:
__attribute__((location(0x100))) extern struct PERIPH peripheral;
The noinit and persistent attributes apply to the ROM initialization model and allow an application to avoid initializing certain global variables during a reset. The alternative RAM initialization model initializes variables only when the image is loaded; no variables are initialized during a reset. See the "RAM Model vs. ROM Model" section and its subsections in the
The noinit attribute can be
used on uninitialized variables; it prevents those variables from being set to 0
during a reset. The persistent attribute can be used on initialized
variables; it prevents those variables from being initialized during a reset. By
default, variables marked noinit or persistent will be placed in sections named
.TI.noinit
and .TI.persistent
,
respectively. The location of these sections is controlled by the linker command
file. Typically .TI.persistent sections are placed in FRAM for devices that support
FRAM and .TI.noinit sections are placed in RAM. Also see Section 5.8.24.
The packed attribute may be applied to individual fields within a struct or union. The packed attribute for structure and union fields is available only when there is hardware support for unaligned accesses.
The retain attribute has the same effect as the RETAIN pragma (Section 5.8.31). That is, the section that contains the variable will not be omitted from conditionally linked output even if it is not referenced elsewhere in the application.
The section attribute when used on a variable has the same effect as the DATA_SECTION pragma. See Section 5.8.8
The used attribute is defined in GCC 4.2 (see http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Variable-Attributes.html#Variable-Attributes).
The weak attribute has the same effect as the WEAK pragma (Section 5.8.35).