 |
|
 |
MAEC TOOL NEWS:
MAECT-M3T-NC30WA-021001D
Note on C Compilers M3T-NC30WA, M3T-NC79WA, and M3T-NC77WA
|
Please take note of the following problem in using C compilers (with an assembler and integrated development environment) M3T-NC30WA, M3T-NC79WA, and M3T-NC77WA:
- On defining the data type of an array within a structure or union using a typedef statement
- Products and Versions Concerned
- M16C/60, M16C/30, M16C/20, and M16C/10 series of MCUs
- M3T-NC30WA V.1.00 Release 1 -- V.5.00 Release 2
- 79xx series of MCUs
- M3T-NC79WA V.2.00 Release 1 -- V.4.10 Release 1A
- 77xx series of MCUs
- M3T-NC77WA V.3.00 Release 1 -- V.5.20 Release 4
- Description
When the data type of an array within a structure or union is defined using a typedef statement, and then a variable is declared to be of the defined type with the near, far, or const qualifier being added, incorrect code may be generated or System Error may arise as follows:
- In M3T-NC30WA V.1.00 Release 1--V.2.20 Release 1, incorrect code may be generated. (And a warning message is displayed at linking.)
- In M3T-NC30WA V.3.00 Release 1--V.5.00 Release 2, System Error may arise.
- In M3T-NC79WA and M3T-NC77WA, incorrect code may be generated.
- Conditions
- This problem may occur if the following five conditions are satisfied:
- (1) A structure or union is defined.
- (2) The data type of an array within the structure or union in (1) is defined using a typedef statement.
- (3) A variable is declared to be of the type defined in (2).
- (4) The near, far, or const qualifier is added to the declaration in (3). (The const qualifier is a condition required only by M3T-NC30WA.)
- (5) The structure or union in (1) is referenced.
- Example
--------------------------------------------------------------------------
struct tag { /* Condition (1) */
long l;
char c;
};
typedef struct tag ARR[3]; /* Condition (2) */
far const ARR dat /* Conditions (3),and (4) */
= { 1, 2, 3, 4, 5, 6 };
void func(int i)
{
char c;
c = dat[i].c + 1; /* Condition (5) */
}
--------------------------------------------------------------------------
- Workaround
- Place a qualifier of the same type as used in (4) before the array in the typedef statement in (2).
[Example]
-------------------------------------------------------------------------
struct tag {
long l;
char c;
};
typedef struct tag far ARR[3]; /* Place another far before ARR */
far const ARR dat = { 1, 2, 3, 4, 5, 6 };
void func(int i)
{
char c;
c = dat[i].c + 1;
}
-------------------------------------------------------------------------
- Schedule of Fixing the Problem
We plan to fix this problem in our next release.
|
 |