This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib] print formats for FAST and LEAST types


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]