CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Printf printing percent character possible bug

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dprice100



Joined: 29 Mar 2007
Posts: 3

View user's profile Send private message

Printf printing percent character possible bug
PostPosted: Thu Mar 29, 2007 6:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 29, 2007 5:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Mar 30, 2007 2:41 am     Reply with quote

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







PostPosted: Fri Mar 30, 2007 2:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Mar 30, 2007 5:02 am     Reply with quote

Ok that's a very interesting tip - thanks very much!

Dave.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group