ARM Technical Support Knowledge Articles

INITIALIZING AN ABSOLUTELY LOCATED VARIABLE

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I have declared a global variable using:

unsigned char xdata foo _at_ 0x2000 = 5;

However, upon compilation I get the following error:

Error 274: 'foo': absolute specifier illegal

How can I initialize an absolutely located variable?

ANSWER

You cannot both specify a location for a variable and initialize it at the same time. The best solution is to initialize the variable seperately in an intitialization routine. For example:

void init_globals(void)
{
  foo = 5;
}

which is then called from the main function.

MORE INFORMATION

SEE ALSO

Article last edited on: 2005-07-15 12:54:03

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