When porting my CCSv4.2 code to CCSv5.1, I noticed a possible bug in the sprintf function. when I do
char buffer[LARGE_ENOUGH_SIZE];
sprintf(buffer, "prompt: %d", a_int_num);
I have only one digit correct, all the following digits are 0xFFs
e.g. if the a_int_num is 5, I got the string "prompt: 5" which is correct;
if the a_int_num is 456, I got the string "prompt: 4\FF\FF", so the second and third digits, instead of ascii code of '5' and '6', the buffer content at those location are 0xFF.
it doesn't matter the width option, if I use "%3d", %ld, I have the same error
however, all floating point formats are OK, if I use %g, %f, %5.2f, etc. those formats are all correct, just the integars formating results are wrong.
Everything worked in CCSv4.24
Is this a possible bug, or I did something wrong? I used full printf support option.
Did you extend your heap_size? Granted that it worked in 4.x, but heap problems can appear random.
What target are you using? Is it the MSP430? If so, what compiler version is associated with your project?
Best Regards,Lisa
Hi Randy,
I just thought I would check if there is any update with your enquiry?
You are probably suffering from SDSCM00042077, which is fixed in compiler version 4.0.1
Thanks, everyone! As Archaeologist suggested, after updating the CGT to v4.02, the problem is solved.
I thought I would mention as I ran into the same problem. Where %i doesn't work properly, %d seems to do fine. Using %d looks to be the simplest solution.
Best, Dan.