| ||||||||
Technical Support Support Resources Product Information | C51: ERROR 258 (MSPACE ILLEGAL IN STRUCT/UNION)Information in this article applies to:
SYMPTOMSI 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. CAUSEThe 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. RESOLUTIONRemove '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];
Last Reviewed: Monday, November 08, 2004 | |||||||
| ||||||||