floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
7.11k stars 501 forks source link

Add explicit cast to convert void* to ImTextureID to fix a Clang C++ compile time error. #1137

Closed someposer closed 1 month ago

someposer commented 1 month ago

Fixes the following compiler error when using Sokol headers in a C++ project.

In file included from src/application.cpp:12:
libs/sokol/util/sokol_imgui.h:2434:24: error: incompatible pointer to integer conversion assigning to 'ImTextureID' (aka 'unsigned long long') from 'void *'
 2434 |     io->Fonts->TexID = simgui_imtextureid(_simgui.default_font);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

This fix is similar to #1134 however, it passes the tests.

floooh commented 1 month ago

Thanks! The reason why https://github.com/floooh/sokol/pull/1134 currently doesn't build is because this dependency is still pinned to ImGui 1.91.1: https://github.com/fips-libs/fips-cimgui

Did you test your fix with the latest Dear ImGui version? I'm surprised that only this one cast is needed.

PS: ah ok, #1134 fixes the public API, which tbh is the cleaner solution :) I will look into both PRs later this week, but I will probably merge #1134 and close this PR, apologies in advance :)

floooh commented 1 month ago

Closing in favor of #1134 (which I just merged), nonetheless, many thanks for submitting the PR :)