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

vsprintf: available in ccs?

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



Joined: 18 Feb 2010
Posts: 2

View user's profile Send private message

vsprintf: available in ccs?
PostPosted: Fri May 07, 2010 7:10 am     Reply with quote

As the object, is the vsprintf available in ccs compiler?
Thanks
d
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 07, 2010 1:17 pm     Reply with quote

Not specifically. CCS has sprintf. In this link they say they support
variable argument lists, but I've never tried it, and don't know if it works.
http://www.ccsinfo.com/content.php?page=varpara
pippo1234



Joined: 07 May 2010
Posts: 1

View user's profile Send private message

PostPosted: Fri May 07, 2010 4:03 pm     Reply with quote

Tested the sprintf with variable parameters but it does not work.
I think is necessary to write a vsprinft from scratch.
Anyone know a workaround?
P
bkamen



Joined: 07 Jan 2004
Posts: 1619
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri May 07, 2010 5:46 pm     Reply with quote

There's a typo in the sample at that link, but I got it to compile..

Just didn't run it.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
allenhuffman



Joined: 17 Jun 2019
Posts: 680
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Oct 20, 2026 8:38 am     Reply with quote

I ran into a use for this today, and ended up here. Can confirm no vargs support in sprintf.

I have a bunch of places where I populate a buffer that will be returned in a "get debug data" message, and was hoping to make them more clever.

Code:
// Log what happened.
char buffer[80];

sprintf (buffer, "%d current %f > %u",
    index, current, currentLimit);

populateDebugDataBuffer (buffer, sizeof(buffer));


Ah well... what's a few more bytes between friends.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?

Using: 24FJ256GA106, 24EP256GP202, 24FJ64GA002 and 24FJ1024GA606.
Ttelmah



Joined: 11 Mar 2010
Posts: 20148

View user's profile Send private message

PostPosted: Tue Oct 20, 2026 12:05 pm     Reply with quote

CCS does support variable argument lists, but the problem with printf,
is that it doesn't have support built in for the format string to handle this.
So extend the number of arguments, and the argument string runs out,
and the code doesn't work.
If you are using a constant format for each item, you can make it work
by having your own function accepting the variable argument list, and
having this pass the arguments one by one to a standard printf, with a
single format string. This does work. You can generate this as a macro
and your own function, to make it behave like vsprintf.
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