Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

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

Open 1vanK opened this issue 1 year ago • 4 comments

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,

1vanK avatar Dec 05 '24 23:12 1vanK

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++?

RobLoach avatar Dec 11 '24 18:12 RobLoach

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?

klei1984 avatar Jan 13 '25 10:01 klei1984

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?

Xeverous avatar Jan 16 '25 13:01 Xeverous

For GLFW I have just disabled this warning for now in nuklear: https://github.com/glfw/glfw/commit/d30d63313c5876f9ce8770f79cd59dd7109a768e

dougbinks avatar Jul 06 '25 10:07 dougbinks