From dc4a07c49a256f4a2c7dcb35d1f4fa3556d57d1c Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 26 Dec 2015 14:59:07 +0100 Subject: [PATCH] Fixed various Clang -Weverything warnings --- imgui.cpp | 4 ---- imgui_draw.cpp | 11 ++++++++++- imgui_internal.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 4b31b2e50..6b7fff957 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3793,7 +3793,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ if (window_pos_center) { // Center (any sort of window) - ImRect fullscreen_rect(GetVisibleRect()); SetWindowPos(ImMax(style.DisplaySafeAreaPadding, fullscreen_rect.GetCenter() - window->SizeFull * 0.5f)); } else if (flags & ImGuiWindowFlags_ChildMenu) @@ -3883,10 +3882,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_ // Modal window darkens what is behind them if ((flags & ImGuiWindowFlags_Modal) != 0 && window == GetFrontMostModalRootWindow()) - { - ImRect fullscreen_rect(GetVisibleRect()); window->DrawList->AddRectFilled(fullscreen_rect.Min, fullscreen_rect.Max, GetColorU32(ImGuiCol_ModalWindowDarkening, g.ModalWindowDarkeningRatio)); - } // Draw window + handle manual resize ImRect title_bar_rect = window->TitleBarRect(); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 5f8a0aa52..da3e682ff 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -31,6 +31,14 @@ #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #define snprintf _snprintf #endif + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok. +#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it. +#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness // +#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier // +#endif #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used #endif @@ -55,6 +63,7 @@ namespace IMGUI_STB_NAMESPACE #ifdef __clang__ #pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse. #pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wmissing-prototypes" #endif @@ -1174,7 +1183,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_d ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) { int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4; - void* compressed_ttf = ImGui::MemAlloc(compressed_ttf_size); + void* compressed_ttf = ImGui::MemAlloc((size_t)compressed_ttf_size); Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf); ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges); ImGui::MemFree(compressed_ttf); diff --git a/imgui_internal.h b/imgui_internal.h index 810c2cd77..25a03e2bc 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -161,7 +161,7 @@ enum ImGuiTreeNodeFlags_ enum ImGuiSliderFlags_ { - ImGuiSliderFlags_Vertical = 1 << 0, + ImGuiSliderFlags_Vertical = 1 << 0 }; enum ImGuiSelectableFlagsPrivate_