Technical Support

C51: CAN STRUCT MEMBERS RESIDE IN DIFFERENT MEMORY SPACES?

QUESTION

In C51, can I declare a structure where elements are of different memory types? For example:

struct xxx
  {
  float data float_value;
  unsigned char data uc_value;
  unsigned int data ui_value;
  unsigned char bdata bit_banger;
  };

ANSWER

No. This is not possible in ANSI C. In fact, the C compiler should emit an error message similar to the following:

*** ERROR 258 IN LINE 6:
'float_value': mspace illegal in struct/union

Since a structure is a single data object, it can only reside in a single data space or memory space. If you need to split the members of a structure among several memory areas, you will have to break them into multiple structures: one for each memory space.

Last Reviewed: Wednesday, August 03, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure