← Back to team overview

dolfin team mailing list archive

Re: vsnprintf alternative

 

On Sat, Jun 16, 2007 at 12:00:01AM +0200, Garth N. Wells wrote:

> Is there a C++ alternative to using the function "vsnprintf" (it's used on
> log.cpp and XMLFile.cpp and perhaps elsewhere). The problem is that it gives a
> compile error under Cygwin. Quite a while ago a replaced "snprintf" with some
> std::string functions to avoid this problem.
> 
> Garth

The only place where this is strictly needed is in log.cpp where one
needs to handle a variable number of arguments.

There are a few possible solutions:

1. Does changing the include from <stdarg.h> to <stdarg> help?
stdarg.h is deprecated for C++ so this should be done anyway.

2. Does vsprintf() work as an alternative to vsnprintf()? The
difference is that for vsnprintf() one can set a limit for the size of
the buffer used (but we can get around this by manually checking the
string length).

/Anders


References