Browse Source

Backends: Fixes zealous warnings (#5760)

ocornut 2 years ago
parent
commit
8a6911b894

+ 11 - 0
backends/imgui_impl_opengl2.cpp

@@ -44,6 +44,13 @@
 #include <stdint.h>     // intptr_t
 #endif
 
+// Clang/GCC warnings with -Weverything
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-macros"                      // warning: macro is not used
+#pragma clang diagnostic ignored "-Wnonportable-system-include-path"
+#endif
+
 // Include OpenGL header (without an OpenGL loader) requires a bit of fiddling
 #if defined(_WIN32) && !defined(APIENTRY)
 #define APIENTRY __stdcall                  // It is customary to use APIENTRY for OpenGL function pointer declarations on all platforms.  Additionally, the Windows OpenGL header needs APIENTRY.
@@ -285,3 +292,7 @@ void    ImGui_ImplOpenGL2_DestroyDeviceObjects()
 {
     ImGui_ImplOpenGL2_DestroyFontsTexture();
 }
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif

+ 5 - 2
backends/imgui_impl_opengl3.cpp

@@ -107,17 +107,20 @@
 #include <TargetConditionals.h>
 #endif
 
-// Clang warnings with -Weverything
+// Clang/GCC warnings with -Weverything
 #if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wold-style-cast"         // warning: use of old-style cast
 #pragma clang diagnostic ignored "-Wsign-conversion"        // warning: implicit conversion changes signedness
+#pragma clang diagnostic ignored "-Wunused-macros"          // warning: macro is not used
+#pragma clang diagnostic ignored "-Wnonportable-system-include-path"
+#pragma clang diagnostic ignored "-Wcast-function-type"     // warning: cast between incompatible function types (for loader)
 #endif
 #if defined(__GNUC__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpragmas"                  // warning: unknown option after '#pragma GCC diagnostic' kind
 #pragma GCC diagnostic ignored "-Wunknown-warning-option"   // warning: unknown warning group 'xxx'
-#pragma GCC diagnostic ignored "-Wcast-function-type"       // warning: cast between incompatible function types
+#pragma GCC diagnostic ignored "-Wcast-function-type"       // warning: cast between incompatible function types (for loader)
 #endif
 
 // GL includes

+ 10 - 0
backends/imgui_impl_sdl2.cpp

@@ -72,6 +72,12 @@
 #include "imgui.h"
 #include "imgui_impl_sdl2.h"
 
+// Clang warnings with -Weverything
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"  // warning: implicit conversion from 'xxx' to 'float' may lose precision
+#endif
+
 // SDL
 #include <SDL.h>
 #include <SDL_syswm.h>
@@ -632,3 +638,7 @@ void ImGui_ImplSDL2_NewFrame()
     // Update game controllers (if enabled and available)
     ImGui_ImplSDL2_UpdateGamepads();
 }
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif

+ 11 - 0
backends/imgui_impl_sdl3.cpp

@@ -24,6 +24,12 @@
 #include "imgui.h"
 #include "imgui_impl_sdl3.h"
 
+// Clang warnings with -Weverything
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"  // warning: implicit conversion from 'xxx' to 'float' may lose precision
+#endif
+
 // SDL
 #include <SDL3/SDL.h>
 #include <SDL3/SDL_syswm.h>
@@ -565,3 +571,8 @@ void ImGui_ImplSDL3_NewFrame()
     // Update game controllers (if enabled and available)
     ImGui_ImplSDL3_UpdateGamepads();
 }
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+

+ 10 - 0
backends/imgui_impl_sdlrenderer.cpp

@@ -31,6 +31,12 @@
 #include <stdint.h>     // intptr_t
 #endif
 
+// Clang warnings with -Weverything
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wsign-conversion"    // warning: implicit conversion changes signedness
+#endif
+
 // SDL
 #include <SDL.h>
 #if !SDL_VERSION_ATLEAST(2,0,17)
@@ -248,3 +254,7 @@ void ImGui_ImplSDLRenderer_DestroyDeviceObjects()
 {
     ImGui_ImplSDLRenderer_DestroyFontsTexture();
 }
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif