 |
|
 |
RENESAS TOOL NEWS [August 16, 2003: RSO-M3T-NC308WA_2-030816D]
A Note on Using C Compilers M3T-NC308WA, M3T-NC30WA, M3T-NC79WA, and M3T-NC77WA
|
Please take note of the following problem in using the M3T-NC308WA, M3T-NC30WA, M3T-NC79WA, and M3T-NC77WA C compilers (with an assembler and integrated development environment):
- On arguments of formatted input/output functions
- Products and Versions Concerned
- M3T-NC308WA V.1.00 Release 1 through V.5.10 Release 1
- for the M32C/80 and M16C/80 series MCUs
- M3T-NC30WA V.1.00 Release 1 through V.5.10 Release 1
- for M16C/60, M16C/30, M16C/20, and M16C/10 series MCUs
- M3T-NC79WA V.2.00 Release 1 through V.4.10 Release 1A
- for the 79xx series MCUs
- M3T-NC77WA V.3.00 Release 1 through V.5.20 Release 4
- for the 77xx series MCUs
- Description
When the field width in the format specification of the following input/output functions is specified using the zero flag and an asterisk * not a decimal number but a character string is displayed:
- fprintf
- printf
- sprintf
- vfprintf
- vprintf
- vsprintf
For example, the flags in the printf("%0*d", keta, val) format specification denote the following:
| 0: | to right-align a decimal number and supply 0s enough to fill the number of digits to be displayed |
| *: | to interpret argument "keta" as the number of digits to be displayed |
| d: | to interpret argument "val" as a variable of type int and display it in a decimal number |
However, an asterisk * that follows zero flag is not correctly interpreted to be a character in the format string, character string "*d" is displayed.
- 2.1 Example
-
--------------------------------------------------------
#include <stdio.h>
int main(void)
{
printf("%0*d\n",4,123);
}
--------------------------------------------------------
- 2.2 Workaround
- Specify the field width in a decimal number.
--------------------------------------------------------
#include <stdio.h>
int main(void)
{
printf("%04d\n",123);
}
--------------------------------------------------------
- Schedule of Fixing the Problem
We plan to fix this problem in our next release of the products.
|
 |