alloc_section

Allocates variable in specified section. Controls section attribute specification for variables.

Syntax

#pragma alloc_section(var1,var2,..., "r;attribute-list")

Arguments

var

variable that can be used to define a symbol in the section

"r;attribute-list"

a comma-separated list of attributes; defined values are: 'short' and 'long'

Description

The alloc_section pragma places the listed variables, var1, var2, etc., in the specified section. This pragma controls section attribute specification for variables. The compiler decides whether the variable, as defined by var1/var2/etc, should go to a "data", "bss", or "rdata" section.

The section name is enclosed in double quotation marks. It should be previously introduced into the program using #pragma section. The list of comma-separated variable names follows the section name after a separating comma.

All listed variables are necessarily defined before this pragma, in the same translation unit and in the same scope. The variables have static storage; their linkage does not matter in C modules, but in C++ modules they are defined with the extern "C" linkage specification.

Example

The following example illustrates how to use the pragma.

#pragma alloc_section(var1, "r;short")
int var1 = 20;
#pragma alloc_section(var2, "r;short")
extern int var2;

Submit feedback on this help topic

Copyright © 1996-2011, Intel Corporation. All rights reserved.