Skip to main content

IAR Embedded Workbench for RX 5.20

location

In this section:
Syntax
#pragma location={address|NAME}
Parameters

address

The absolute address of the global or static variable for which you want an absolute location.

NAME

A user-defined section name—cannot be a section name predefined for use by the compiler and linker.

Description

Use this pragma directive to specify the location—the absolute address—of the global or static variable whose declaration follows the pragma directive. The directive can also take a string specifying a section for placing either a variable or a function whose declaration follows the pragma directive. Do not place variables that would normally be in different sections—for example, variables declared as __no_init and variables declared as const—in the same named section.

Example
#pragma location=0x2000
__no_init volatile char PORT1; /* PORT1 is located at address
                                  0x2000 */

#pragma segment="FLASH"
#pragma location="FLASH"
__no_init char PORT2; /* PORT2 is located in section FLASH */

/* A better way is to use a corresponding mechanism */
#define FLASH _Pragma("location=\"FLASH\"")
/* ... */
FLASH __no_init int i; /* i is placed in the FLASH section */
See also

Controlling data and function placement in memory and Declare and place your own sections.