View previous topic :: View next topic |
Author |
Message |
dprice100
Joined: 29 Mar 2007 Posts: 3
|
Printf printing percent character possible bug |
Posted: Thu Mar 29, 2007 6:42 am |
|
|
Hello, I have come across a problem - using PCM on a PIC16F877- has anyone else seen this one:
Code: | printf("AGITATOR %% Hz");
|
On version 3.0.0.13, the "%%" directive prints a single percent sign as expected.
On the newer version 3.6.0.115 it prints a double percent "%%".
Has anyone else come across this? is it a bug?
I can think of a workaround (i.e. use "%c37" instead) so no urgency on this!
Dave Price
Dragon Design Ltd
Weymouth, Dorset, UK. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 29, 2007 5:52 pm |
|
|
The numbers that you posted are from right-clicking the CCS icon
and then looking at the Version tab in the Properties window.
That's not the "real" compiler version. Compiler versions are
numbers such as 3.191, 3.249, 4.030, etc.
Look at the top of the .LST file to find the version number. |
|
|
dprice100
Joined: 29 Mar 2007 Posts: 3
|
|
Posted: Fri Mar 30, 2007 2:41 am |
|
|
Sorry yes that is how I found version numbers!
the version numbers from the .lst files are:
Earlier version 3.067
Later version 3.249
Dave. |
|
|
Ttelmah Guest
|
|
Posted: Fri Mar 30, 2007 2:59 am |
|
|
I'd suspect it probably is a bug. However there is no support now for 3.249, so it'll probably never be fixed. I'll try it on one of the more modern compilers, to see if it is still there.
As a 'comment', the most efficient way to send a constant prompt lke this, is with:
Code: |
putc("AGITATOR % Hz");
|
This is a little CCS extension, which avoids the overhead of the 'printf' interpreter (looking for the '%' signs etc.). In fact if I remember correctly, 'printf', in latter versions, by default behaves the same, if there is no further argument on the line (so it 'knows' that it doesn't have to interpret any '%' signs present). This would explain what you are seeing. Effectively the optimiser is saying 'no arguments are present, so the string only needs to be directly printed'...
Best Wishes |
|
|
dprice100
Joined: 29 Mar 2007 Posts: 3
|
|
Posted: Fri Mar 30, 2007 5:02 am |
|
|
Ok that's a very interesting tip - thanks very much!
Dave. |
|
|
|