ARM Technical Support Knowledge Articles

VARIABLE ZERO INITIALIZIATION

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

The C51 User's Guide states that the file INIT.A51 initializes variables that were explicitly initialized in the 'C' source. Does it also initialize variables that are implicitly initialized to zero, or does it rely on the zeroing of memory in STARTUP.A51 to do this?

Is there a difference in the following two statements or are they identical?

static int xdata xi;
static int xdata xi = 0;

INITIALIZATION

ANSWER

Yes, the compiler relies on the zero initialization in the STARTUP file. For strict ANSI compliance it is important that the settings match with your hardware.

When you make explicit assignments such as:

static int xdata xi = 0;

the variables get set to zero by the INIT.A51 file. This behaviour allows you to use non-volatile memory for variables.

MORE INFORMATION

SEE ALSO

Article last edited on: 2007-01-18 15:09:45

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