From 2a67aeaa3d9427a28cab0bf7b9f39a76e119ccaa Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 30 Jul 2018 15:27:09 +0200 Subject: [PATCH] Visual Studio: calling into _vsnprintf. (#1085) --- imgui.cpp | 5 +++++ imgui_demo.cpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 41cd5be8..426d1964 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1257,6 +1257,11 @@ static const char* ImAtoi(const char* src, TYPE* output) // Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm. // B) When buf==NULL vsnprintf() will return the output size. #ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS + +#if defined(_MSC_VER) && !defined(vsnprintf) +#define vsnprintf _vsnprintf +#endif + int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) { IM_ASSERT(fmt != NULL); diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 5e2e4232..28f7c80f 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -36,7 +36,8 @@ #ifdef _MSC_VER #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen -#define snprintf _snprintf +#define snprintf _snprintf +#define vsnprintf _vsnprintf #endif #ifdef __clang__ #pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.