ARM Technical Support Knowledge Articles

WHEN/WHERE ARE GLOBAL AND STATIC VARIABLES INITIALIZED?

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

How does the compiler handle variables that are initialized when declared? If I write something like the following in a function:

static int temp = 1;

or initialize a global variable, how will the variable be initialized? I do not see anything in the STARTUP.A51 file to move initialized data from ROM to RAM.

ANSWER

The initial values of global and static variables are stored in ROM in a segment called ?C_INITSEG. They are then copied to the relevent RAM locations after the code in STARTUP.A51 has been executed and before the main() function is called. The code that performs the variable initialization may be found in the file INIT.A51 inside the LIB folder.

We strongly recommend that you do not modify the INIT.A51 file.

MORE INFORMATION

SEE ALSO

Article last edited on: 2005-07-15 12:12:58

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential