Fix to allow compiling in unity builds where stb_rectpack/stb_truetype may be already included in the same compilation unit.

This commit is contained in:
omar
2018-05-08 11:02:38 +02:00
parent f13f10e725
commit 280c05e4f8
3 changed files with 7 additions and 2 deletions

View File

@ -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