ARM Technical Support Knowledge Articles

ERROR 258 (MSPACE ILLEGAL IN STRUCT/UNION)

Applies to: C51 C Compiler

Answer


Information in this article applies to:


SYMPTOMS

I declare an array of structures in xdata as follows:

struct foo
{
  unsigned char xdata x,y;
};

struct foo bar[3];

This generates:

ERROR 258: 'x': MSPACE ILLEGAL IN STRUCT/UNION.

CAUSE

The contents or members of a structure are allocated sequentially in memory. This means that a structure resides in a single memory area. For this reason, structure members may not have their own memory spaces.

A structure variable, however, may be located in a specific memory space.

RESOLUTION

Remove 'xdata' from the structure declaration and change the array or struct declaration to:

xdata struct foo bar[3];

If you examine the Symbol Table in the map (.M51) file generated by the linker, you will see something like:

  VALUE           TYPE          NAME
  ----------------------------------
  X:0000H         PUBLIC        bar

The 'X' at the start of the address indicates the array is stored in xdata.

If you declare the array at the same time you declare the structure, then you would specify xdata as follows:

xdata struct foo
{
  unsigned char x,y;
} bar[3];

Article last edited on: 2004-11-08 11:55:14

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