This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

error C258:mspace illegal in struct/union

Hi all
i want to read RTC time parameters.
RTC is treated as one of memory location,it gets enabled when parameters are refered.
following where the codes:

struct tm{
unsigned char xdata second  _at_(0xe000);
unsigned char xdata minute  _at_(0xe002);
unsigned char xdata hour    _at_(0xe004);
};

void main()
{
 struct tm time;
 printf("seconds %x",time.second)
 ...
}
On compiling above code compiler gives following error:
error C258:mspace has illegal in struct/union.

but if code in struct are modified as follows:
struct tm{
unsigned char second _at_(0xe000);
}
Code compiles without any error but RTC was not getting enabled by
addr-decod logic even on disabling internal xram from AUXR.

but if my codes are as follows than things work perfect:

xdata unsigned char second  _at_(0xe000);
xdata unsigned char minute  _at_(0xe002);
xdata unsigned char hour    _at_(0xe004);

void main()
{
  printf("\nseconds %x",second);
  printf("\nminutes %x",minutes);
  printf("\nhours   %x",hour);
}

1)what is wrong with the defn in struct ?
2)i cannot just define struct as xdata because
addr-decoding logic should enable RTC when required,
so how can i declare struct variable so that no error is generated and RTC is enabled ?

3)what if i try to define more than one struct var for above case ?
eg
 struct tm{
 unsigned char xdata second  _at_(0xe000);
 unsigned char xdata minute  _at_(0xe002);
 unsigned char xdata hour    _at_(0xe004);
 };

 void main()
 {
  struct tm time1,time2;
  ......
 

will var in time1 and time2 be placed in same location ?

Regards
Naresh

0