Ensure consistent imgui enum types when OR-ing#691
Open
slowriot wants to merge 1 commit intoepezent:masterfrom
Open
Ensure consistent imgui enum types when OR-ing#691slowriot wants to merge 1 commit intoepezent:masterfrom
slowriot wants to merge 1 commit intoepezent:masterfrom
Conversation
There was a problem hiding this comment.
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
ImGuiButtonFlagsto prevent-Wenum-enum-conversionwhen combining public and private flag enums. - Updates
ButtonBehaviorflag 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
ImGuiButtonFlags_in include/imgui/imgui.h:1865: AllowOverlap, MouseButtonLeft/Right/MiddleImGuiButtonFlagsPrivate_in include/imgui/imgui_internal.h:1031: PressedOnClick, PressedOnDoubleClick, FlattenChildrenButtonBehavior()still takesImGuiButtonFlags, 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.