Skip to content

Ensure consistent imgui enum types when OR-ing#691

Open
slowriot wants to merge 1 commit intoepezent:masterfrom
slowriot:enum_conversion_fix
Open

Ensure consistent imgui enum types when OR-ing#691
slowriot wants to merge 1 commit intoepezent:masterfrom
slowriot:enum_conversion_fix

Conversation

@slowriot
Copy link
Copy Markdown

This fixes #688 and similar issues.

This was a latent bug going back to 2021, now breaks with modern Clang diagnostics and most recent Imgui master.

ImPlot is building plot_button_flags by OR-ing values from two different Dear ImGui enum families:

  • public ImGuiButtonFlags_ in include/imgui/imgui.h:1865: AllowOverlap, MouseButtonLeft/Right/Middle
  • internal ImGuiButtonFlagsPrivate_ in include/imgui/imgui_internal.h:1031: PressedOnClick, PressedOnDoubleClick, FlattenChildren

ButtonBehavior() still takes ImGuiButtonFlags, but the bitwise expression itself mixes distinct enum types, so Clang emits -Wenum-enum-conversion, and as warnings are treated as errors, the build fails.

This PR casts enums to a consistent type when OR-ing them together.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR resolves build failures triggered by newer Clang diagnostics (and recent Dear ImGui changes) by avoiding bitwise-OR operations between different enum types (public vs internal ImGui button flag enums, and similarly mixed ImPlot flag enums in examples/demo).

Changes:

  • Casts the first operand in ImGui button-flag bitwise expressions to ImGuiButtonFlags to prevent -Wenum-enum-conversion when combining public and private flag enums.
  • Updates ButtonBehavior flag expressions used for plots, legends, and subplot splitters to use the consistent cast pattern.
  • Adjusts ImPlot spec/demo examples that OR item flags with specialized item-type flags to start from an ImPlotItemFlags-typed value.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
implot.h Updates documentation examples to avoid mixed-enum OR by casting to ImPlotItemFlags.
implot.cpp Fixes mixed ImGui public/private enum OR-ing by casting to ImGuiButtonFlags before combining flags.
implot_demo.cpp Updates demo code to avoid mixed-enum OR by casting to ImPlotItemFlags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Bitwise operation between different enumeration types ('ImGuiButtonFlags_' and 'ImGuiButtonFlagsPrivate_') is deprecated

2 participants