Renesas Technology, Tools FAQs
Last Updated: July 22, 2003
Document Number: 03062001_e
Q.
Will the variables declared in a C source program be assigned to the memory in the order originally declared?
A.
No., the order in which the variables are assigned in the memory will not necessarily be the order in which they were declared in the
C source program. There is no way to predict in what order the variables will be assigned to the memory by examining the
descriptive content of the program.
However, the following are a few ways to determine the assigned location of the variables when describing them in the source
program.
Declare the variables as structure members:
The order of memory assignments of structure members will be the same as the order of the declarations.
Example:
----------------------------------
struct {
int a;
int b;
int c;
} order;
----------------------------------
The structure members will be assigned to the memory in the following order: order.a, order.b, order.c
●
Create an assembly file from the C language file with the compiler, then edit the file:
Create a C language file describing only variable declarations. Then, specify the -S option (create an assembly source file)
and compile the file. Open the newly created assembly source file and edit the file so that the order of the variable definitions
is the order in which you want to assign them to memory.
* Variables will be assigned to the memory in the order defined in the assembly file.
●
Define variables in Assembler:
Define the variables in the assembly source code.
* The variables will be assigned to the memory in the order defined in the assembly source.
●
Specify the variable addresses with expansion function "#pragma ADDRESS":
When using this method, you can determine the order of the variables and the assigned addresses at the same time.
Example:
----------------------------------
#pragma ADDRESS var1 0x10000
#pragma ADDRESS var2 0x20000
char var1;
static char var2;
void func(void)
{
}
----------------------------------
For more details concerning the #pragma ADDRESS function, please refer to "A.3 #pragma Expansion Function" in the
[M3T-CC32R User's Manual (C Compiler Version)].
●
Top of Page | Back to Previous Page
Terms of Use Privacy Policy
(C)2004 Renesas Technology Corp., All Rights Reserved.
Kommentare zu diesen Handbüchern