1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-25 02:04:23 +00:00

Fixed a VS 2017 compiler warning

This commit is contained in:
hogliux 2017-03-14 14:55:22 +00:00
parent bba9c7e9ed
commit 08483a0138
2 changed files with 17 additions and 11 deletions

View file

@ -1867,8 +1867,7 @@ bool String::containsNonWhitespaceChars() const noexcept
return false;
}
// Note! The format parameter here MUST NOT be a reference, otherwise MS's va_start macro fails to work (but still compiles).
String String::formatted (const String pf, ... )
String String::formattedRaw (const char* pf, ...)
{
size_t bufferSize = 256;
@ -1877,19 +1876,22 @@ String String::formatted (const String pf, ... )
va_list args;
va_start (args, pf);
#if JUCE_WINDOWS
HeapBlock<wchar_t> temp (bufferSize);
const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, pf.toWideCharPointer(), args);
#elif JUCE_ANDROID
#if JUCE_ANDROID
HeapBlock<char> temp (bufferSize);
int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf.toUTF8(), args);
int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf, args);
if (num >= static_cast<int> (bufferSize))
num = -1;
#else
#else
String wideCharVersion (pf);
HeapBlock<wchar_t> temp (bufferSize);
const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toWideCharPointer(), args);
const int num = (int)
#if JUCE_WINDOWS
_vsnwprintf
#else
vswprintf
#endif
(temp.getData(), bufferSize - 1, wideCharVersion.toWideCharPointer(), args);
#endif
va_end (args);
if (num > 0)

View file

@ -919,7 +919,8 @@ public:
on the platform, it may be using wchar_t or char character types, so that even string
literals can't be safely used as parameters if you're writing portable code.
*/
static String formatted (const String formatString, ... );
template <typename... Args>
static String formatted (const String& formatStr, Args... args) { return formattedRaw (formatStr.toRawUTF8(), args...); }
//==============================================================================
// Numeric conversions..
@ -1274,6 +1275,9 @@ private:
// to bools (this is possible because the compiler can add an implicit cast
// via a const char*)
operator bool() const noexcept { return false; }
//==============================================================================
static String formattedRaw (const char*, ...);
};
//==============================================================================