Keil Logo

C51: INITIALIZING AN ABSOLUTELY LOCATED VARIABLE


Information in this article applies to:

  • C51 Version 5.50

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

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.