From 7d2cd0e6ff96f8e802a06c79e5946a083d76025c Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 24 Oct 2017 20:19:32 +0200 Subject: [PATCH] Added IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS support in imconfig.h (#1038) --- imconfig.h | 9 ++++++--- imgui.cpp | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/imconfig.h b/imconfig.h index e557fa065..b175c9b26 100644 --- a/imconfig.h +++ b/imconfig.h @@ -13,6 +13,9 @@ //#define IMGUI_API __declspec( dllexport ) //#define IMGUI_API __declspec( dllimport ) +//---- Don't define obsolete functions names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names +//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS + //---- Include imgui_user.h at the end of imgui.h //#define IMGUI_INCLUDE_IMGUI_USER_H @@ -24,13 +27,13 @@ //---- It is very strongly recommended to NOT disable the test windows. Please read the comment at the top of imgui_demo.cpp to learn why. //#define IMGUI_DISABLE_TEST_WINDOWS -//---- Don't define obsolete functions names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names -//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS +//---- Don't implement ImFormatString(), ImFormatStringV() so you can reimplement them yourself. +//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS //---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends) //#define IMGUI_USE_BGRA_PACKED_COLOR -//---- Implement STB libraries in a namespace to avoid conflicts +//---- Implement STB libraries in a namespace to avoid linkage conflicts //#define IMGUI_STB_NAMESPACE ImGuiStb //---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4. diff --git a/imgui.cpp b/imgui.cpp index 629598540..0b56b6354 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1011,6 +1011,7 @@ static const char* ImAtoi(const char* src, int* output) // MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size). // 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. +#ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS int ImFormatString(char* buf, int buf_size, const char* fmt, ...) { IM_ASSERT(buf_size > 0); @@ -1033,6 +1034,7 @@ int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args) buf[w] = 0; return w; } +#endif // #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Pass data_size==0 for zero-terminated strings // FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.