ARM Technical Support Knowledge Articles

CAN STRUCT MEMBERS RESIDE IN DIFFERENT MEMORY SPACES?

Applies to: C51 C Compiler

Answer

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.

Article last edited on: 2005-08-03 11:41:44

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