-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark alternative ImColor constructors as constexpr #6656
Conversation
An ImColor variable cannot be marked as constexpr / constinit when constructed using one of these constructors, as they are not marked as constexpr.
Merged, thank you! |
This is actually breaking build with VS2015
But works with VS2017 onward. |
Also see MinGW https://github.com/ocornut/imgui/actions/runs/5701044022/job/15451390799 In file included from main.cpp:4:
../../imgui.h: In constructor 'ImColor::ImColor(int, int, int, int)':
../../imgui.h:2471:197: error: 'constexpr' constructor does not have empty body
constexpr ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; } and GCC In file included from main.cpp:4:
../../imgui.h: In constructor ‘ImColor::ImColor(int, int, int, int)’:
../../imgui.h:2471:197: error: ‘constexpr’ constructor does not have empty body
2471 | constexpr ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; } I don't understand why CI didn't run on this prior to merging, this would be something else to investigate. |
Not sure why it would break the build on these compilers. I only tested on VS2022 with v143 build tools. I assume this can be fixed by declaring the |
After testing it on godbolt.org, I was unable to reproduce the issue on any C++11 compiler, even as far back as x86-64 gcc 6.1 |
I have pushed 19ae142 Note that I tried to mark the variable as |
Do you remember if you approved the workflow run? CI doesn't run by default on PRs from first time contributors. (See here for details.) |
An ImColor variable cannot be marked as constexpr / constinit when constructed using one of these constructors, as they are not marked as constexpr.