Controlling data and function placement in memory
The compiler provides different mechanisms for controlling placement of functions and data objects in memory. To use memory efficiently, you should be familiar with these mechanisms and know which one is best suited for different situations. You can use:
The
@operator and the#pragma locationdirective for absolute placement.Using the
@operator or the#pragma locationdirective, you can place individual global and static variables at absolute addresses. Note that it is not possible to use this notation for absolute placement of individual functions. For more information, see Data placement at an absolute location.The
@operator and the#pragma locationdirective for section placement.Using the
@operator or the#pragma locationdirective, you can place individual functions, variables, and constants in named sections. The placement of these sections can then be controlled by linker directives. For more information, see Data and function placement in sections.The
@operator and the#pragma locationdirective for register placementUse the @ operator or the
#pragma locationdirective to place individual global and static variables in registers. The variables must be declared__no_init. This is useful for individual data objects that must be located in a specific register.Using the
‑‑sectionoption, you can set the default segment for functions, variables, and constants in a particular module. For more information, see ‑‑section.