Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
Other
9.17k stars 553 forks source link

Suppress compiler `possible loss of data` warning with explicit cast #606

Closed pabdulin closed 8 months ago

pabdulin commented 8 months ago

Hi! Building Nuklear with MSVC (Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33134 for x64) results in following W3+ level warnings:

Nuklear\nuklear.h(7665): error C2220: the following warning is treated as an error
Nuklear\nuklear.h(7665): warning C4244: '=': conversion from 'const float' to 'nk_byte', possible loss of data
Nuklear\nuklear.h(7666): warning C4244: '=': conversion from 'const float' to 'nk_byte', possible loss of data
Nuklear\nuklear.h(7667): warning C4244: '=': conversion from 'const float' to 'nk_byte', possible loss of data

This fix resolves the issue by explicit safe cast which assumed to be safe. Thanks!

pabdulin commented 8 months ago

@RobLoach I've made the changes to nuklear_color.c, thanks!