| View previous topic :: View next topic |
| Author |
Message |
darkeagle
Joined: 18 Feb 2010 Posts: 2
|
| vsprintf: available in ccs? |
Posted: Fri May 07, 2010 7:10 am |
|
|
As the object, is the vsprintf available in ccs compiler?
Thanks
d |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
 |
pippo1234
Joined: 07 May 2010 Posts: 1
|
|
Posted: Fri May 07, 2010 4:03 pm |
|
|
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
|
|
Posted: Fri May 07, 2010 5:46 pm |
|
|
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
|
|
Posted: Tue Oct 20, 2026 8:38 am |
|
|
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
|
|
Posted: Tue Oct 20, 2026 12:05 pm |
|
|
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. |
|
 |
|