diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 03083c155..4e6c376d8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -69,6 +69,7 @@ Other Changes: - Fonts: When building font atlas, glyphs that are missing in the fonts are not using the glyph slot to render a dummy/default glyph. Saves space and allow merging fonts with overlapping font ranges such as FontAwesome5 which split out the Brands separately from the Solid fonts. (#1703, #1671) - Misc: Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769) +- Misc: Fix to allow compiling in unity builds where stb_rectpack/stb_truetype may be already included in the same compilation unit. - Demo: Fixed Overlay: Added a context menu item to enable freely moving the window. - Examples: Calling IMGUI_CHECKVERSION() in the main.cpp of every example application. - Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices). diff --git a/imgui.cpp b/imgui.cpp index c5b16151b..092054af6 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2594,10 +2594,10 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) //----------------------------------------------------------------------------- -void* ImGui::MemAlloc(size_t sz) +void* ImGui::MemAlloc(size_t size) { GImAllocatorActiveAllocationsCount++; - return GImAllocatorAllocFunc(sz, GImAllocatorUserData); + return GImAllocatorAllocFunc(size, GImAllocatorUserData); } void ImGui::MemFree(void* ptr) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index e67d55193..eadc92860 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -91,6 +91,7 @@ namespace IMGUI_STB_NAMESPACE #pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers #endif +#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) #ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION #define STBRP_STATIC #define STBRP_ASSERT(x) IM_ASSERT(x) @@ -101,7 +102,9 @@ namespace IMGUI_STB_NAMESPACE #else #include "stb_rect_pack.h" #endif +#endif +#ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) #ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION #define STBTT_malloc(x,u) ((void)(u), ImGui::MemAlloc(x)) #define STBTT_free(x,u) ((void)(u), ImGui::MemFree(x)) @@ -116,6 +119,7 @@ namespace IMGUI_STB_NAMESPACE #else #include "stb_truetype.h" #endif +#endif #ifdef __GNUC__ #pragma GCC diagnostic pop