Skip to content
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

warning C5054: operator '|': deprecated between enumerations of different types #751

Open
1vanK opened this issue Dec 5, 2024 · 3 comments

Comments

@1vanK
Copy link

1vanK commented Dec 5, 2024

1>F:\my_games\dviglo2d\repo\third_party\external\nuklear\repo\nuklear.h(3719,37): warning C5054: operator '|': deprecated between enumerations of different types
1>(compiling source file '../../../repo/apps/nuklear_demo/src/app.cpp')
1>F:\my_games\dviglo2d\repo\third_party\external\nuklear\repo\nuklear.h(5622,47): warning C5054: operator '|': deprecated between enumerations of different types
1>(compiling source file '../../../repo/apps/nuklear_demo/src/app.cpp')
1>F:\my_games\dviglo2d\repo\third_party\external\nuklear\repo\nuklear.h(5623,42): warning C5054: operator '|': deprecated between enumerations of different types
1>(compiling source file '../../../repo/apps/nuklear_demo/src/app.cpp')
1>F:\my_games\dviglo2d\repo\third_party\external\nuklear\repo\nuklear.h(5715,46): warning C5054: operator '|': deprecated between enumerations of different types
1>(compiling source file '../../../repo/apps/nuklear_demo/src/app.cpp')
NK_EDIT_FIELD   = NK_EDIT_SIMPLE|NK_EDIT_SELECTABLE|NK_EDIT_CLIPBOARD,
NK_PANEL_SET_POPUP = NK_PANEL_SET_NONBLOCK|NK_PANEL_POPUP,
NK_PANEL_SET_SUB = NK_PANEL_SET_POPUP|NK_PANEL_GROUP
NK_WINDOW_NOT_INTERACTIVE = NK_WINDOW_ROM|NK_WINDOW_NO_INPUT,
@RobLoach
Copy link
Contributor

C++ will expect a static_cast between the types. Unsure of the best approach here. Perhaps a macro that handles the change between C vs C++?

@klei1984
Copy link

C-style casts to basic types expected by the particular call sites would silence the warnings and would be C89 as well as C++ compliant.

Example:

    nk_do_edit(ws, out, edit, (nk_uint)NK_EDIT_FIELD|(nk_uint)NK_EDIT_AUTO_SELECT,
        filters[filter], text_edit, &style->edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);

Would this be an accepted solution?

@Xeverous
Copy link
Contributor

Question: why these constants come from different enumeration types? Shouldn't it either 1) be a single enumeration 2) be a function that accepts 2 enumerations?

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

No branches or pull requests

4 participants