View previous topic :: View next topic |
Author |
Message |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
bug in sprintf with int32 (version 3.212) |
Posted: Mon Oct 18, 2004 8:00 am |
|
|
Can someone please confirm this:
The following lines of code don't appear to do what it should!
Code: | int32 sdisplay;
sdisplay = 10000; // manually set pdisplay variable for de-bug
sprintf(line1,"S%04lu",sdisplay); |
For values of sdisplay 0 to 9999 the resultant string is correct (i.e. S0000 to S9999) however if sdisplay is 10000 then the string generated by sprintf is S10000 even though I have restricted it to 4 characters (it should be S0000)
The restriction doesn't appear to work for int32 length? Changing sdisplay to a int16 works OK. |
|
|
Guest
|
|
Posted: Mon Oct 18, 2004 8:40 pm |
|
|
confirmed.
well, not a serious bug, might call it a CCS's non-ANSI feature ?
workaround: sprintf(line1,"S%04lu", (int16) sdisplay); |
|
|
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
|
Posted: Tue Oct 19, 2004 2:29 am |
|
|
I ended up casting it into another int16 local as I have been programmed a long time ago (mainly a nasty little H8 complier to be honest) not to try and do ‘clever’ things like a cast inside a function call but having just tried it, it works fine!
It’s always nice to fine a bug (human nature I guess!). There is a nasty one in the PCW IDE. I usually shoot off and do other things like check email etc. while the PIC is being programmed in the debugger; “attached” as it were. Yesterday I thought I would select “Help > Contents” to have a look at some help files… don’t do this while the IDE is downloading code to the PIC it crashes badly!
To be honest with you the current development systems by CCS is actually very stable and a joy to use. The support guys are good and always fix things quickly (even when it’s my fault!). I also code windows in Delphi and Borland could learn a few tricks from CCS IMHO. |
|
|
|