rxi / microui

A tiny immediate-mode UI library
MIT License
3.29k stars 239 forks source link

Fix msvc warnings #60

Open rdck opened 1 year ago

rdck commented 1 year ago

The Microsoft C compiler at warning level 3 (/W3) complains about various integer casts. I assume microui doesn't intend to handle the cases where these casts would overflow. I think it's worth making the casts explicit, to express that this is the intended behavior.

rilysh commented 1 year ago

MSVC showing the integer casting warning message because microui uses the wrong type-casting for strlen. strlen on both 32-bit and 64-bit in x86 and amd64 returns an unsigned long but microui has unsigned as the type. See here.

There are other points I saw where microui uses that same wrong type for a specific purpose. MSVC explicitly sees microui as a C++ file thus it leads to explicit casting since C++ requires you to do so.