From e08d56bed623e9bbe881e1124af39f8eec419ba3 Mon Sep 17 00:00:00 2001 From: Breno Cunha Queiroz Date: Sun, 25 Oct 2026 14:32:05 +0100 Subject: [PATCH] fix: mixed ImGuiButtonFlags enums rejected by clang in C++26 The legend and plot button flags ORed ImGuiButtonFlags_AllowOverlap, from the public ImGuiButtonFlags_ enum, with values from the internal ImGuiButtonFlagsPrivate_ enum. Bitwise operations between different enumeration types are deprecated in C++20 and removed in C++26, so clang++ -std=c++2c now rejects implot3d.cpp with "invalid bitwise operation between different enumeration types", and GCC warns with -Wdeprecated-enum-enum-conversion. Cast the first operand to ImGuiButtonFlags, as ImGui does for its own mixed flags, so the expression is computed as int with the same value as before. The ImPlot3DSpec usage comments in implot3d.h get the same cast so code copied from them stays valid in C++26. This mirrors epezent/implot#710. --- implot3d.cpp | 4 ++-- implot3d.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/implot3d.cpp b/implot3d.cpp index 409583a..c28f93c 100644 --- a/implot3d.cpp +++ b/implot3d.cpp @@ -461,7 +461,7 @@ void RenderLegend() { // Test hover (using the clamped rect so off-screen overflow does not register) // clang-format off - const ImGuiButtonFlags legend_button_flags = ImGuiButtonFlags_AllowOverlap + const ImGuiButtonFlags legend_button_flags = (ImGuiButtonFlags)ImGuiButtonFlags_AllowOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_MouseButtonLeft @@ -2380,7 +2380,7 @@ void HandleInput(ImPlot3DPlot& plot) { ImGuiIO& IO = ImGui::GetIO(); // clang-format off - const ImGuiButtonFlags plot_button_flags = ImGuiButtonFlags_AllowOverlap + const ImGuiButtonFlags plot_button_flags = (ImGuiButtonFlags)ImGuiButtonFlags_AllowOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_MouseButtonLeft diff --git a/implot3d.h b/implot3d.h index 3c9450d..e7451fd 100644 --- a/implot3d.h +++ b/implot3d.h @@ -370,7 +370,7 @@ enum ImPlot3DColormap_ { // spec.LineColor = ImVec4(1,0,0,1); // spec.LineWeight = 2.0f; // spec.Marker = ImPlot3DMarker_Circle; -// spec.Flags = ImPlot3DItemFlags_NoLegend | ImPlot3DLineFlags_Segments; +// spec.Flags = (ImPlot3DItemFlags)ImPlot3DItemFlags_NoLegend | ImPlot3DLineFlags_Segments; // ImPlot3D::PlotLine("MyLine", xs, ys, zs, 100, spec); // // 2. Inline using ImPlot3DProp,value pairs (order does NOT matter): @@ -379,7 +379,7 @@ enum ImPlot3DColormap_ { // ImPlot3DProp_LineColor, ImVec4(1,0,0,1), // ImPlot3DProp_LineWeight, 2.0f, // ImPlot3DProp_Marker, ImPlot3DMarker_Circle, -// ImPlot3DProp_Flags, ImPlot3DItemFlags_NoLegend | ImPlot3DLineFlags_Segments +// ImPlot3DProp_Flags, (ImPlot3DItemFlags)ImPlot3DItemFlags_NoLegend | ImPlot3DLineFlags_Segments // }); struct ImPlot3DSpec { ImVec4 LineColor = IMPLOT3D_AUTO_COL; // Line color; IMPLOT3D_AUTO_COL will use next Colormap color