[flac-dev] vsnprintf_s and vsnprintf

lvqcl lvqcl.mail at gmail.com
Sat Sep 20 17:51:13 PDT 2014


lvqcl wrote:

> I would like to know opinions of other people... Especially because I'm not
> very familiar with MinGW. Anyone?

Is it safe to use __mingw_vsnprintf? If yes, then flac_snprintf can look like:

int flac_snprintf(char *str, size_t size, const char *fmt, ...)
{
	va_list va;
	int rc;

	va_start (va, fmt);

#if defined _MSC_VER
	rc = vsnprintf_s (str, size, _TRUNCATE, fmt, va);
	if (rc < 0)
		rc = something_that_makes_sense;
#elif defined __MINGW32__
	rc = __mingw_vsnprintf (str, size, fmt, va);
#else
	rc = vsnprintf (str, size, fmt, va);
#endif
	va_end (va);

	return rc;
}


More information about the flac-dev mailing list