 |
|
 |
RENESAS TOOL NEWS on June 1, 2005: RSO-M3T-NC308WA_1-050601D
A Note on Using C-Compiler Packages
M3T-NC308WA and M3T-NC30WA
--On Passing a Pointer or Address
to a Function as an Argument-- |
Please take note of the following problem in using the M3T-NC308WA and
M3T-NC30WA C-compiler packages (these C-compiler packages are used for the
M16C family of MCUs):
- On passing a pointer or address to a function as an argument
- Products and Versions Concerned
- M3T-NC308WA V.5.20 Release 02
(for the M32C/90, M32C/80 and M16C/80 series)
- M3T-NC30WA V.5.30 Release 02
(for the M16C/60, M16C/30, M16C/20, M16C/10, M16C/Tiny and R8C/Tiny series)
- Description
When making a call to a function that takes a pointer as an argument,
a warning message may be displayed even if a correct type of argument is passed to the function.
- 2.1 Conditions
- This problem occurs if the following conditions are all satisfied:
| (1) |
The parameter of a function to call is a pointer type not qualified with "const". |
| (2) |
The argument of the function in (1) is a pointer or address qualified with "const". |
| (3) |
The type pointed to by the pointer qualified with "const" in (2) is the same as the one pointed to by the pointer in (1). |
- 2.2 Example
-
-------------------------------------------------------------
void subr2( int * ); /* Conditions (1) and (3) */
extern int var;
int * const p = &var; /* Conditions (2) and (3) */
void mainr2(void)
{
subr2( p ); /* Condition (2) */
}
-------------------------------------------------------------
- Workaround
Explicitly convert the type of the argument to that of the parameter using the cast operator.
-------------------------------------------------------------
void subr2( int * );
extern int var;
int * const p = &var;
void mainr2(void)
{
subr2( (int*)p ); /* Cast operator used */
}
-------------------------------------------------------------
- Schedule of Fixing the Problem
We plan to fix the problem in the next release of the products.
|
 |