Backends: fixed misc zealous Clang warnings.

This commit is contained in:
ocornut
2025-11-18 16:34:35 +01:00
parent 9afc62d087
commit 6ae32c696a
4 changed files with 15 additions and 8 deletions

View File

@@ -44,7 +44,7 @@ struct ImGui_ImplDX12_InitInfo
D3D12_GPU_DESCRIPTOR_HANDLE LegacySingleSrvGpuDescriptor;
#endif
ImGui_ImplDX12_InitInfo() { memset((void*)this, 0, sizeof(*this)); }
ImGui_ImplDX12_InitInfo() { memset(this, 0, sizeof(*this)); }
};
// Follow "Getting Started" link and check examples/ folder to learn about using backends!

View File

@@ -101,8 +101,10 @@
// Clang 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 "-Wold-style-cast" // warning: use of old-style cast
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning: declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is.
#endif
// GLFW
@@ -957,8 +959,8 @@ static void ImGui_ImplGlfw_GetWindowSizeAndFramebufferScale(GLFWwindow* window,
int display_w, display_h;
glfwGetWindowSize(window, &w, &h);
glfwGetFramebufferSize(window, &display_w, &display_h);
float fb_scale_x = (w > 0) ? (float)display_w / w : 1.0f;
float fb_scale_y = (h > 0) ? (float)display_h / h : 1.0f;
float fb_scale_x = (w > 0) ? (float)display_w / (float)w : 1.0f;
float fb_scale_y = (h > 0) ? (float)display_h / (float)h : 1.0f;
#if GLFW_HAS_X11_OR_WAYLAND
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(window);
if (!bd->IsWayland)

View File

@@ -17,6 +17,11 @@
#ifndef IMGUI_DISABLE
#include "imgui_impl_null.h"
// Clang/GCC warnings with -Weverything
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse.
#endif
IMGUI_IMPL_API bool ImGui_ImplNull_Init()
{
ImGui_ImplNullPlatform_Init();
@@ -75,7 +80,7 @@ IMGUI_IMPL_API void ImGui_ImplNullRender_NewFrame()
{
}
void ImGui_ImplNullRender_UpdateTexture(ImTextureData* tex)
static void ImGui_ImplNullRender_UpdateTexture(ImTextureData* tex)
{
if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantDestroy)
tex->SetStatus(ImTextureStatus_OK);

View File

@@ -819,8 +819,8 @@ static void ImGui_ImplSDL3_GetWindowSizeAndFramebufferScale(SDL_Window* window,
#else
int display_w, display_h;
SDL_GetWindowSizeInPixels(window, &display_w, &display_h);
float fb_scale_x = (w > 0) ? (float)display_w / w : 1.0f;
float fb_scale_y = (h > 0) ? (float)display_h / h : 1.0f;
float fb_scale_x = (w > 0) ? (float)display_w / (float)w : 1.0f;
float fb_scale_y = (h > 0) ? (float)display_h / (float)h : 1.0f;
#endif
if (out_size != nullptr)