erincatto / box2d

Box2D is a 2D physics engine for games
https://box2d.org
MIT License
8.36k stars 1.55k forks source link

[MSVC] Compile error in sample_benchmark.cpp due to recent changes in ocornut/imgui #835

Closed NEIL-smtg closed 3 weeks ago

NEIL-smtg commented 3 weeks ago

Hi, I work on MSVC compiler testing, and we regularly build popular open-source project such as box2d, with development builds of MSVC in order to find and fix regressions before they ship and cause problems for you.

Recently, as I tried to build box2d from source, I encountered the following error:

C:\gitP\erincatto\box2d\samples\sample_benchmark.cpp(1329,37): error C2662: 'const ImFontGlyph *ImFont::FindGlyph(ImWchar)': cannot convert 'this' pointer from 'const ImFont' to 'ImFont &'
C:\gitP\erincatto\box2d\samples\sample_benchmark.cpp(1329,31): note: Conversion loses qualifiers
C:\gitP\erincatto\box2d\build\imgui\imgui.h(3566,33): note: see declaration of 'ImFont::FindGlyph'
C:\gitP\erincatto\box2d\samples\sample_benchmark.cpp(1329,37): note: while trying to match the argument list '(const char)'

I found that this issue is likely due to recent changes made in imgui.h and imgui_draw.cpp within the ocornut/imgui repository. The relevant commit can be found here: https://github.com/ocornut/imgui/commit/0bde57c25a90ee1b99e511385611db6185d318f8#diff-cbc47f9fc55eb2c19b4be92d1c1e137bb8b72d072588ab3cb4bcba88576d14cbR3474

Could you please let me know if you are planning to update your code to align with these recent changes? Or would you prefer that I report this issue directly to the ocornut/imgui.

Repro Steps:

  1. Open x64 native tools command prompt for VS 2022
  2. git clone https://github.com/erincatto/box2d.git
  3. cd erincatto/box2d
  4. mkdir build_amd64
  5. cd build_amd64
  6. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0 .. 2>&1
  7. msbuild /m /p:Platform=x64 /p:Configuration=Release box2d.sln /t:Rebuild 2>&1

Build log: b2d.txt

erincatto commented 3 weeks ago

Fixed in #829