This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[newlib] print formats for FAST and LEAST types
- From: Andre Vieira <Andre dot SimoesDiasVieira at arm dot com>
- To: newlib at sourceware dot org
- Date: Tue, 14 Jul 2015 12:17:21 +0100
- Subject: [newlib] print formats for FAST and LEAST types
- Authentication-results: sourceware.org; auth=none
Hello,
Kevin Bracey commented on Launchpad that he was having issues with a
mismatch between <inttypes.h> and <stdint.h> when printing an
int_fast32_t. See
https://answers.launchpad.net/gcc-arm-embedded/+question/269083
This is due to the fact that on targets where the size of âintâ and
âlongâ are equal and 32 bits, the current header files will configure
the type of int_fast32_t to be âintâ and PRIdFAST32 to be âldâ and make
printf thus expect a âlongâ. The macroâs used in <stdint.h> come from
âgcc/config/newlib-stdint.hâ.
This leads to a print format warning when -Wformat and we are exploring
two possible ways of fixing it and would like your views on which path
would be best to take.
Approach 1)
Change the print formats for FAST (and LEAST) to reflect the types used
in âgcc/config/newlib-stdint.hâ. Less intrusive change. Though the fact
that the approach for FASTNN and LEASTNN types is different from the one
for INTNN types where âlongâ is chosen over âintâ if they are equally
sized does make us feel slightly uneasy.
Approach 2)
Change âgcc/config/newlib-stdint.hâ such that for targets where the size
of âintâ and âlongâ are the same, âlongâ is used for FASTNN and LEASTNN
types where âintâ was used previously. This would mimic the behavior of
INTNN types, though it is more intrusive.
Kind Regards,
Andre Vieira