03-03-2008 05:07 AM
03-03-2008 07:07 AM
This was briefly mentioned on the forums before here:
http://forums.ni.com/ni/board/message?board.id=180&message.id=27474&query.id=154974#M27474
and a few other places if you search for snprinft.
I've been close to downloading a portable library before and now I have... There are a few options out there:
http://www.ijs.si/software/snprintf/
http://www.jhweiss.de/software/snprintf.html
I'm linking to the 2nd one now and will let you know if I run into any problems.
gvan
03-03-2008 07:52 AM
04-04-2008 12:30 PM - edited 04-04-2008 12:30 PM
04-04-2008 01:20 PM - edited 04-04-2008 01:20 PM
04-04-2008 01:27 PM
Thanks Mert!
It is good to hear that vsnprintf might be added soon.
I did mange to get the C99 version of the snprintf.c going in CVI without too much trouble this afternoon.
Hope all is well at NI.
Scott Y.
08-21-2008 06:17 AM
Hello Scott,
your wrote that you got the C99 version of snprintf working with CVI. I tried the same thing!
Can you explain how you did it? Perhaps you have a little example program ?
Thanks a lot.
Alex
08-21-2008 11:17 AM
alternatively, i discovered that the Windows Platform SDK includes a "strsafe.h" header defining a set of StringCb* and StringCch* functions which are good replacements for sprintf, snprintf and the likes. those functions are not straight replacement since argument ordering or return value may differ from their C counterparts, but writing an adapter should not be difficult.
it seems this header is not part of the SDK included with CVI, but you may download the latest SDK from microsoft and use it.
by the way, is there a chance we have an updated SDK coming with CVI in a near future ?
08-21-2008 12:12 PM
That is a much better solution. I wish I had found those SDK functions instead of adding an entire library to all my code.
HRESULT StringCchPrintf(
LPTSTR pszDest,
size_t cchDest,
LPCTSTR pszFormat,
...
);
int snprintf(char *str, size_t size, const char *format, ...);
It should be easy to make those line up with just a very thin header file.
I think that must be the "right" way to do it until CVI is updated to support snprintf() and the like.
Scott.
08-21-2008 12:26 PM
The Beta for CVI 9.0 includes an updated windows SDK (I'm not sure how up to date, but appears faily recent, certainly better then the current WIN2000 RC1 SDK)
The 9.0 Beta also has suppport for more C99 extentions including snprintf and vsnprintf.
Greg