[newlib] print formats for FAST and LEAST types

Andre Vieira Andre.SimoesDiasVieira@arm.com
Tue Jul 14 13:30:00 GMT 2015


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



More information about the Newlib mailing list