Sets the current data segment.
#pragma DATA_SEG <name>|DEFAULT
<name>
The name of the data segment being defined.This segment must be explicitly allocated within the PLACEMENT block in the link parameter file. For more information, refer to the chapter Linker Issues of the Build Tools Utilities reference manual.
DEFAULT
This pragma sets the current data segment: either the default data segment (that is, DEFAULT_RAM), or a user-defined segment. All the variables subsequently declared are allocated into that segment by the linker.
The following listing exemplifies the correct usage of the DATA_SEG pragma:
/* p.h */ #pragma DATA_SEG MY_RAM extern int x; #pragma DATA_SEG DEFAULT extern int y; /* p.c */ #pragma DATA_SEG MY_RAM int x; #pragma DATA_SEG DEFAULT int y; /* main.c */ #include "p.h" void main(void) { x = 5; y = 10; }
The following listing contains examples of improper DATA_SEG pragma usage:
#pragma CONST_SEG MY_RAM #pragma DATA_SEG MY_RAM /** incorrect: the same segment name used with different segment types **/ #pragma DATA_SEG MY_RAM extern int x; #pragma DATA_SEG DEFAULT extern int x; /** incorrect: variable 'x' is declared in two different segments **/ /* p.h */ #pragma DATA_SEG MY_RAM extern int x; #pragma DATA_SEG DEFAULT extern int y; #pragma DATA_SEG MY_RAM extern int z; #pragma DATA_SEG DEFAULT /* p.c */ #pragma DATA_SEG MY_RAM int x; #pragma DATA_SEG DEFAULT int y, z; /** incorrect: variable 'z' is declared in segment MY_RAM and defined in segment DEFAULT **/