| ||||||||
Technical Support Support Resources Product Information | C51: CAN STRUCT MEMBERS RESIDE IN DIFFERENT MEMORY SPACES?QUESTIONIn 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;
};
ANSWERNo. 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 | |||||||
| ||||||||