printf/sprintf width and precision

cancel
Showing results for 
Search instead for 
Did you mean: 

printf/sprintf width and precision

3,234 Views
Contributor III
I have a custom project that we took from CW 6.0 to CW 7.1.1 recently.  We moved to the C_4i_CF_SZ_MSL.a and C++_4i_CF_SZ_MSL.a libraries because using the non-SZ libraries increased our flash ROM size by nearly 1MB (up from 1.2mb).

But in doing so, it appears that printf and sprintf, when using %2.2d, %*d, etc seems to ignore the width and prescision parameters.

For example
sprintf(tmp, "%.2d.%2.2d.%*2d", event, event, event);

Would yield the string tmp looking like
2d.2d.2d

It appears that . and * are not valid now even though the help files seem to indicate they should be.

I trace the code and it goes into printf_tiny_io.c.

Any opinions?  Or anyone know why the stock libraries to link in changed so drastically between CW 6.0 and CW 7.1.1?
Labels (1)
0 Kudos
3 Replies

9 Views
Senior Contributor II
See:
 
 
I think that has all your answers -- the SZ libraries prune out as much functionality as possible to reduce their size...  Sometimes you have to prune some of it back in. :smileyhappy:
 
-- Rich
 
0 Kudos

9 Views
Contributor III
Well,

I tried your printf files, and the compiler complains about trying to overload the std::smileytongue:rintf routines (amoung others). So I gave that up and decided to optimize the libraries myself, which seems to work except then it complains that the set_printf routine the is in tiny IO (and used with console IO) is not available.

I feel like I can't win for trying here.
0 Kudos

9 Views
Contributor III
Again, finally got it with some linker work, so, that appears to be the easiest solution (using custom functions for specific ones we need) rather than customizing libraries and trying to get everyone to use the right ones.
0 Kudos